QQ登录

只需一步,快速开始

Write the database table design to represent the data model below, including...

[复制链接]
福虎生威 发表于 2022-2-15 07:59:05 [显示全部楼层] 回帖奖励 倒序浏览 阅读模式 0 754
Write the database table design to represent the  data model below, including tables, the proper placement of the foreign key,  and referential integrity constraint.   Illustrate the implementation of valid minimum cardinalities that can be  present this relationship?  '


ANSWER
The cardinality of the above design is MANY-To-ONE. This means many students can have only one advisor. Or One advisor can have many students.
Table design for the given diagram is as follows.
Create table STUDENT(StudentID int, StuName varchar(20), StuMajor varchar(20), StuPhone varchar(15), primary key(StudentID));
Create table ADVISOR(AdvisorID int, AdvName varchar(20), AdvOffice varchar(20), AdvPhone varchar(15), primary key(AdvisorID));
Create table STUDENTADVISOR(StudentID int, AdvisorID int, primary key(StudentID,AdvisorID), foreign key(StudentID) references STUDENT(StudentID), foreign key(AdvisorID) references ADVISOR(AdvisorID));


Answer & Explanation
[size=1.875]Solved by verified expert[size=1.875]






Answer)
Here we are having the Student table and the Advisor table.
The Student relation is as StudentID(Primary key), StuName, StuMajor, StuPhone
Advisor relation is as AdvisorID(Primary key), AdvName, AdvOffice, AdvPhone

[size=2.25]Step-by-step explanation


The valid minimum cardinalities that can be present this relationship is:
Advisor : Student = 1 : N

That is 1 Advisor that can be related to more than one student.

Thus the table design would be like:
Student(StudentID(Primary key), StuName, StuMajor, StuPhone, AdvisorID (the foreign key which references the AdvisorID of Advisor table))

Advisor(AdvisorID(Primary key), AdvName, AdvOffice, AdvPhone)

Thus the final design for the above requirement is as already explained above:
Student(StudentID, StuName, StuMajor, StuPhone, AdvisorID)
Advisor(AdvisorID, AdvName, AdvOffice, AdvPhone)





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

官方微博
官方微博
模板大全
模板大全
意见
反馈