数据库大题的答案Word文件下载.docx

上传人:b****5 文档编号:15846212 上传时间:2022-11-16 格式:DOCX 页数:38 大小:411KB
下载 相关 举报
数据库大题的答案Word文件下载.docx_第1页
第1页 / 共38页
数据库大题的答案Word文件下载.docx_第2页
第2页 / 共38页
数据库大题的答案Word文件下载.docx_第3页
第3页 / 共38页
数据库大题的答案Word文件下载.docx_第4页
第4页 / 共38页
数据库大题的答案Word文件下载.docx_第5页
第5页 / 共38页
点击查看更多>>
下载资源
资源描述

数据库大题的答案Word文件下载.docx

《数据库大题的答案Word文件下载.docx》由会员分享,可在线阅读,更多相关《数据库大题的答案Word文件下载.docx(38页珍藏版)》请在冰豆网上搜索。

数据库大题的答案Word文件下载.docx

Eachprojectisworkedonbyoneormoregraduatestudents(knownastheproject’sresearchassistants).

Whengraduatestudentsworkonaproject,aprofessormustsupervisetheirworkontheproject.Graduatestudentscanworkonmultipleprojects,inwhichcasetheywillhavea(potentiallydifferent)supervisorforeachone.

Departmentshaveadepartmentnumber,adepartmentname,andamainoffice.

Departmentshaveaprofessor(knownasthechairman)whorunsthedepartment.

Professorsworkinoneormoredepartments,andforeachdepartmentthattheyworkin,atimepercentageisassociatedwiththeirjob.

Graduatestudentshaveonemajordepartmentinwhichtheyareworkingontheirdegree.

Eachgraduatestudenthasanother,moreseniorgraduatestudent(knownasastudentadvisor)whoadviseshimorheronwhatcoursestotake.

DesignanddrawanERdiagramthatcapturestheinformationabouttheuniversity.

UseonlythebasicERmodelhere;

thatis,entities,relationships,andattributes.Besuretoindicateanykeyandparticipationconstraints.

9.ConsidertheuniversitydatabasefromExercise8andtheERdiagramyoudesigned.WriteSQLstatementstocreatethecorrespondingrelationsandcaptureasmanyoftheconstraintsaspossible.Ifyoucannotcapturesomeconstraints,explainwhy.

Answer:

1.createtableprofessors(prof_ssnchar(10),

namechar(64),

ageinteger,

rankinteger,

specialitychar(64),

primarykey(profssn))

2.createtabledepts(dnointeger,

dnamechar(64),

officechar(10),

primarykey(dno))

3.createtableruns(dnointeger,

prof_ssnchar(10),

primarykey(dno,profssn),

foreignkey(profssn)referencesprofessors,

foreignkey(dno)referencesdepts)

4.createtableworkdept(dnointeger,

pc_timeinteger,

primarykey(dno,prof_ssn),

foreignkey(prof_ssn)referencesprofessors,

foreignkey(dno)referencesdepts)

observethatwewouldneedcheckconstraintsorassertionsinsqltoenforcetherulethatprofessorsworkinatleastonedepartment.

5.createtableproject(pidinteger,

sponsorchar(32),

startdatechar(20),

enddatechar(20),

budgetfloat,

primarykey(pid))

6.createtablegraduates(gradssnchar(10),

degprogchar(32),

majorinteger,

primarykey(gradssn),

foreignkey(major)referencesdepts)

notethatthemajortableisnotnecessarysinceeachgraduatehasonlyonemajor

andsothiscanbeanattributeinthegraduatestable.

7.createtableadvisor(seniorssnchar(10),

gradssnchar(10),

primarykey(seniorssn,gradssn),

foreignkey(seniorssn)referencesgraduates,

foreignkey(gradssn)referencesgraduates)

8.createtablemanages(pidinteger,

profssnchar(10),

primarykey(pid,profssn),

foreignkey(pid)referencesprojects)

9.createtableworkin(pidinteger,

foreignkey(profssn)referencesprofessors,

foreignkey(pid)referencesprojects)

observethatwecannotenforcetheparticipationconstraintforprojectsinthe

workintablewithoutcheckconstraintsorassertionsinsql.

10.createtablesupervises(profssnchar(10),

pidinteger,

primarykey(profssn,gradssn,pid),

foreignkey(profssn)referencesprofessors(profssn),

foreignkey(gradssn)referencesgraduates(gradssn),

foreignkey(pid)referencesprojects(pid))

Notethatwedonotneedanexplicit(明确的)tablefortheWorkProjrelationsinceeverytimeaGraduateworksonaProject,heorshemusthaveaSupervisor.

10.Considerthefollowingrelations:

Student(snum:

integer,sname:

string,major:

string,level:

string,age:

integer)

Class(name:

string,meetsat:

string,room:

string,fid:

Enrolled(snum:

integer,cname:

string)

Faculty(fid:

integer,fname:

string,deptid:

Themeaningoftheserelationsisstraightforward;

forexample,Enrolledhasonerecordperstudent-classpairsuchthatthestudentisenrolledintheclass.

WritethefollowingqueriesinSQL.Noduplicatesshouldbeprintedinanyoftheanswers.

1.FindthenamesofallJuniors(level=JR)whoareenrolledinaclasstaughtbyI.Teach.

2.FindtheageoftheoldeststudentwhoiseitheraHistorymajororenrolledin

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 成人教育 > 远程网络教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1