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