【发布时间】:2022-01-16 23:53:01
【问题描述】:
我对数据库设计非常陌生,我正在创建一个小项目以更好地理解它,我正在尝试提出一个新的学校 crm。我从以下架构开始:
create table student(
id int not null,
firstname varchar(100),
lastname varchar(100),
PRIMARY key (id)
);
create table address(
id int not null,
street varchar(30) not null,
city varchar(30) not null,
PRIMARY KEY (id)
);
-- they have own roles for app
create table guardians(
id int not null,
firstname varchar(100),
lastname varchar(100),
primary key (id)
);
-- teacher have own roles
create table teacher(
id int not null,
firstname varchar(100),
lastname varchar(100),
PRIMARY key (id)
)
guardians 和 teachers 将有 password 用于登录门户网站。我创建单独表的原因主要是因为teachers将来可能会有salary、schoolId等列。但是现在如果我看一下这里的架构,大部分firstName、lastname 对所有student、teacher 和guardians 都很常见。
如何为此类可重复的字段名称创建一个公用表?还是这个设计好?我还想要另一个表ROLE,它将在应用程序级别授予权限以更新/插入某些表。不知道我该如何设计它。
【问题讨论】:
标签: database postgresql