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