资源描述:
《数据库系统基础教程第七章答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、SolutionsChapter77.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),studioNameCH
2、AR(30),producerC#INTREFERENCESMovieExec(cert#),PRIMARYKEY(title,year));b)CREATETABLEMovies(titleCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(30),producerC#INTREFERENCESMovieExec(cert#)ONDELETESETNULLONUPDATESETNULL,PRIMARYKEY(title,year));c)CREATETABLEMovies(tit
3、leCHAR(100),yearINT,lengthINT,genreCHAR(10),studioNameCHAR(30),producerC#INTREFERENCESMovieExec(cert#)ONDELETECASCADEONUPDATECASCADE,PRIMARYKEY(title,year));d)CREATETABLEStarsIn(movieTitleCHAR(100)REFERENCESMovie(title),movieYearINT,starNameCHAR(30),PRIMARYKEY(movieTItle,mo
4、vieYear,starName));e)CREATETABLEStarsIn(movieTitleCHAR(100)REFERENCESMovie(title)ONDELETECASCADE,movieYearINT,starNameCHAR(30),PRIMARYKEY(movieTItle,movieYear,starName));7.1.2Todeclaresuchaforeign-keyconstraintbetweentherelationsMovieandStarsIn,valuesofthereferencingattribu
5、tesinMovieshouldappearinMovieStarasuniquevalues.However,basedonprimarykeydeclarationinrelationStarIn,theuniquenessofmoviesisguaranteedwithmovieTitle,movieYear,andstarNameattributes.EvenwithtitleandyearasreferencingattributesthereisnowayofreferencinguniquemoviefromStarsInwit
6、houtstarNameinformation.Therefore,suchaconstraintcannotbeexpressedusingaforeign-keyconstraint.7.1.3ALTERTABLEProductADDPRIMARYKEY(model);ALTERTABLEPCADDFOREIGNKEY(model)REFERENCESProduct(model);ALTERTABLELaptopADDFOREIGNKEY(model)REFERENCESProduct(model);ALTERTABLEPrinterAD
7、DFOREIGNKEY(model)REFERENCESProduct(model);7.1.4ALTERTABLEClassesADDPRIMARYKEY(class);ALTERTABLEShipsADDPRIMARYKEY(name);ALTERTABLEShipsADDFOREIGNKEY(class)REFERENCESClasses(calss);ALTERTABLEBattlesADDPRIMARYKEY(name);ALTERTABLEOutcomesADDFOREIGNKEY(ship)REFERENCESShips(nam
8、e);ALTERTABLEOutcomesADDFOREIGNKEY(battle)REFERENCESBattles(name);7.1.5a)ALTERTABL