这是 ER 图,必须在实现所有约束的 SQL 代码中创建表。我制作了表格并尝试通过外键实现所有关系,我只是想确认这些表格是否正确。
1)部门表:
create table department(dpet_id number primary key, dept_name varchar2(15)
not null);
2)分支表:
create table branch(branch_id varchar2(5) primary number, electives varchar2(10),
dept_id number references department(dept_id));
3) 课程表:
create table course(course_id number primary key, course_name varchar2(10)
not null,branch_id varchar2(5) references branch(branch_id));
4)学生表:
create table student(stud_id number primary key, stud_name varchar2(30) not null,
branch_id varchar2(5) references branch(branch_id);
5) 申请人表:
create table applicant(app_id number primary key, stud_id number constraint fk
references student(stud_id) constraint stu_unq unique);
6) 申请者_分支表:
create table applicant_branch(app_id number references applicant(app_id),
branch_id varchar2(5) references branch(branch_id));
这些表是否符合 ER 图?