我有一個數據庫,通常用戶是中心對象。
在數據庫中我有一個表roles
和users in roles
,所以我可以給用戶不同的權限。
但現在我有一個疑問。
我一個數據庫之前與結構看到這樣的(用戶是在1:1相對於其他表):1對1數據庫設計
User{UserId, Username, Email etc.}
Admin{UserId, some specific columns}
Child{UserId, some specific columns}
Admin{Parent, some specific columns}
和其他表不通過用戶表,但通過Admin, Child and admin.
連接到用戶因爲現在我設計我的數據庫我有用戶和用戶可以是Admin, CompanyManager and Professor
。
我不知道應該像上面展示的那樣設計表格還是僅僅依靠角色?
第一種方法的優點是什麼?
而且在我的商業模式中,用戶不一定是CompanyManager或Professor,所以這實際上是1到0或1的設計。
用這樣的場景設計數據庫的好方法是什麼?
這不是1:1的關係,它是1:0/1 –