资源描述:
《数据库系统基础教程第七章答案.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、7.1.1a)CREATETABLEMovies(titleCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(30),producerC#INT,PRIMARYKEY(title,year),FOREIGNKEY(producerC#)REFERENCESMovieExec(cert#));orCREATETABLEMovies(titleCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(3
2、0),producerC#INTREFERENCESMovieExec(cert#),PRIMARYKEY(title,year));b)CREATETABLEMovies(titleCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(30),producerC#INTREFERENCESMovieExec(cert#)ONDELETESETNULLONUPDATESETNULL,PRIMARYKEY(title,year));c)CREATETABLEM
3、ovies(titleCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(30),producerC#INTREFERENCESMovieExec(cert#)ONDELETECASCADEONUPDATECASCADE,PRIMARYKEY(title,year));d)CREATETABLEStarsIn(movieTitleCHAR(100)REFERENCESMovie(title),movieYearINT,starNameCHAR(30),PR
4、IMARYKEY(movieTItle,movieYear,starName));e)CREATETABLEStarsIn(movieTitleCHAR(100)REFERENCESMovie(title)ONDELETECASCADE,movieYearINT,starNameCHAR(30),PRIMARYKEY(movieTItle,movieYear,starName));7.1.2Todeclaresuchaforeign-keyconstraintbetweentherelationsMovieandSt
5、arsIn,valuesofthereferencingattributesinMovieshouldappearinMovieStarasuniquevalues.However,basedonprimarykeydeclarationinrelationStarIn,theuniquenessofmoviesisguaranteedwithmovieTitle,movieYear,andstarNameattributes.Evenwithtitleandyearasreferencingattributesth
6、ereisnowayofreferencinguniquemoviefromStarsInwithoutstarNameinformation.Therefore,suchaconstraintcannotbeexpressedusingaforeign-keyconstraint.7.1.3ALTERTABLEProductADDPRIMARYKEY(model);ALTERTABLEPCADDFOREIGNKEY(model)REFERENCESProduct(model);ALTERTABLELaptopADD
7、FOREIGNKEY(model)REFERENCESProduct(model);ALTERTABLEPrinterADDFOREIGNKEY(model)REFERENCESProduct(model);7.1.4ALTERTABLEClassesADDPRIMARYKEY(class);ALTERTABLEShipsADDPRIMARYKEY(name);ALTERTABLEShipsADDFOREIGNKEY(class)REFERENCESClasses(calss);ALTERTABLEBattlesAD
8、DPRIMARYKEY(name);ALTERTABLEOutcomesADDFOREIGNKEY(ship)REFERENCESShips(name);ALTERTABLEOutcomesADDFOREIGNKEY(battle)REFERENCESBattles(name);7.1.5a)ALTERTABLEShipsADDFOREIGNK