首页 > 解决方案 > 哪种数据结构最适合可扩展的用户数据库

问题描述

我正在尝试创建一个数据结构,该结构将容纳未知数量的用户,并将随着程序的进行而扩展。我正在使用一个结构,它将有多个实例放入结构中,现在我想知道我应该使用哪种结构来扩展需要随机检查和访问的用户群。

我正在使用的结构:

    struct Bank{
      string userName;
      string password;
      string legalName;
      int accountNum;
      string accountType;
      map<string, int> accountBal;
      list<string> recPayments;
      map<string, int> CardNums;
      map<string, list<string>> transactions;
    };

谢谢

标签: c++c++14

解决方案


当我看到一个像数据库一样行走、像数据库一样游泳、像数据库一样嘎嘎作响的结构时,我称该结构为数据库。

本质上,您尝试创建关系数据库。

struct Account {
  string userName;
  string password;
  string legalName;
  int accountNum;
  string accountType;
};

以及以下关系表。

  map<string, int> accountBal;
  list<string> recPayments;
  map<string, int> CardNums;
  map<string, list<string>> transactions;

推荐阅读