After we have cleared up the object relationship, let's proceed to the design of the database. When modeling a database, the relationship between N and N is generally required to include an association table to indicate the relationship between the two. Preliminary estimate, this system needs at least 10 tables, namely: Permission table, user table, Role table, Group table, User Rights association table, User Role Association table, Role Rights Association table, Group Rights Association table, Group Role Association table, User Group Association table. Of course, it may also lead to some related tables. Let's draw the tables in the PowerDesigner.
The tables and their relationships are as follows:
1. User table
User table (TUser) |
Field name |
Field |
Type |
Note |
Record identification |
tu_id |
bigint |
PK, NOT NULL |
Affiliated organizations |
to_id |
bigint |
FK, NOT NULL |
Login account |
Login_name |
VARCHAR (64) |
NOT NULL |
User password |
Password |
VARCHAR (64) |
NOT NULL |
User name |
Vsername |
VARCHAR (64) |
NOT NULL |
Mobile phone number |
Mobile |
varchar (20) |
|
E-Mail |
Email |
VARCHAR (64) |
|
Creation time |
Gen_time |
Datetime |
NOT NULL |
Logon time |
Login_time |
Datetime |
|
Last logon time |
Last_login_time |
Datetime |
|
Number of Logins |
Count |
bigint |
NOT NULL |
2. Role table
not null
|
Field name |
field |
type |
Note |
role ID |
tr_id |
bigint |
pk, NOT null |
parent role ID |
parent_tr_id |
bigint |
not null |
|
role_name |
varchar () |
Create time |
gen_time |
datetime |
not null |
role description |
desc Ription |
varchar |
  |