简体   繁体   English

在这种情况下如何创建数据库表?

[英]How to create DB tables in this case?

I have created a table called "users" which is having 我创建了一个名为“用户”的表

  1. userID (primary key) userID(主键)
  2. username 用户名
  3. password 密码
  4. name 名称

so now scenario is each user can have n-number of categories which mean userID=1 may have category1, category2, category3 so on and again each categories may have n-number of sub categories. 因此,现在的场景是每个用户可以具有n个类别,这意味着userID = 1可以具有category1,category2,category3,依此类推,每个类别又可以具有n个子类别。 So how can I design my tables? 那么如何设计我的桌子呢? Any suggestions ? 有什么建议么 ?

Simple, the proposed DB Design could be like the following 很简单,建议的数据库设计可能如下所示

 1. tbl_users(uid, uname, password, Name, ...)
 2. tbl_categories(cid, cname, parent_category_id ...) -- self join
 3. tbl_user_categories (uid, cid) -- Mapping table

Some Notes: 一些注意事项:

  • Having sensitive information like user names , passwords and names and other details in one table is not advisable. 建议不要在一个表中包含敏感信息,例如用户名密码和名称以及其他详细信息。
  • It is better start learning using some good tutorials over internet to understand DB concepts 最好通过使用一些很好的互联网教程来开始学习,以了解数据库概念
  • stackoverflow is for specific coding or other specific technical problems you struck with, not for asking DB designs. stackoverflow用于解决您遇到的特定编码或其他特定技术问题,而不用于询问数据库设计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM