数据库系统基础教程第二章答案解析(共19页).doc
《数据库系统基础教程第二章答案解析(共19页).doc》由会员分享,可在线阅读,更多相关《数据库系统基础教程第二章答案解析(共19页).doc(21页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上Exercise 2.2.1aFor relation Accounts, the attributes are:acctNo, type, balanceFor relation Customers, the attributes are:firstName, lastName, idNo, accountExercise 2.2.1bFor relation Accounts, the tuples are:(12345, savings, 12000),(23456, checking, 1000),(34567, savings, 25)For relatio
2、n Customers, the tuples are:(Robbie, Banks, 901-222, 12345),(Lena, Hand, 805-333, 12345),(Lena, Hand, 805-333, 23456)Exercise 2.2.1cFor relation Accounts and the first tuple, the components are: acctNosavings type12000 balanceFor relation Customers and the first tuple, the components are:Robbie firs
3、tNameBanks lastName901-222 idNo12345 accountExercise 2.2.1dFor relation Accounts, a relation schema is:Accounts(acctNo, type, balance)For relation Customers, a relation schema is:Customers(firstName, lastName, idNo, account)Exercise 2.2.1eAn example database schema is:Accounts (acctNo,type,balance)C
4、ustomers (firstName,lastName,idNo,account)Exercise 2.2.1fA suitable domain for each attribute:acctNo Integertype Stringbalance IntegerfirstName StringlastName StringidNo String (because there is a hyphen we cannot use Integer)account IntegerExercise 2.2.1gAnother equivalent way to present the Accoun
5、t relation:acctNobalancetype3456725savings234561000checking1234512000savingsAnother equivalent way to present the Customers relation:idNofirstNamelastNameaccount805-333LenaHand23456805-333LenaHand12345901-222RobbieBanks12345Exercise 2.2.2Examples of attributes that are created for primarily serving
6、as keys in a relation:Universal Product Code (UPC) used widely in United States and Canada to track products in stores.Serial Numbers on a wide variety of products to allow the manufacturer to individually track each product.Vehicle Identification Numbers (VIN), a unique serial number used by the au
7、tomotive industry to identify vehicles.Exercise 2.2.3aWe can order the three tuples in any of 3! = 6 ways. Also, the columns can be ordered in any of 3! = 6 ways. Thus, the number of presentations is 6*6 = 36.Exercise 2.2.3bWe can order the three tuples in any of 5! = 120 ways. Also, the columns can
8、 be ordered in any of 4! = 24 ways. Thus, the number of presentations is 120*24 = 2880Exercise 2.2.3cWe can order the three tuples in any of m! ways. Also, the columns can be ordered in any of n! ways. Thus, the number of presentations is n!m!Exercise 2.3.1aCREATE TABLE Product (makerCHAR(30),modelC
9、HAR(10) PRIMARY KEY,type CHAR(15);Exercise 2.3.1bCREATE TABLE PC (model CHAR(30),speed DECIMAL(4,2),ram INTEGER,hd INTEGER,price DECIMAL(7,2);Exercise 2.3.1cCREATE TABLE Laptop (model CHAR(30),speed DECIMAL(4,2),ram INTEGER,hd INTEGER,screen DECIMAL(3,1),price DECIMAL(7,2);Exercise 2.3.1dCREATE TABL
10、E Printer (model CHAR(30),color BOOLEAN,type CHAR (10),price DECIMAL(7,2);Exercise 2.3.1eALTER TABLE Printer DROP color;Exercise 2.3.1fALTER TABLE Laptop ADD od CHAR (10) DEFAULT none;Exercise 2.3.2aCREATE TABLE Classes (class CHAR(20),type CHAR(5),country CHAR(20),numGuns INTEGER,bore DECIMAL(3,1),
11、displacement INTEGER);Exercise 2.3.2bCREATE TABLE Ships (name CHAR(30),class CHAR(20),launched INTEGER);Exercise 2.3.2cCREATE TABLE Battles (name CHAR(30),date DATE);Exercise 2.3.2dCREATE TABLE Outcomes (ship CHAR(30),battle CHAR(30),result CHAR(10);Exercise 2.3.2eALTER TABLE Classes DROP bore;Exerc
12、ise 2.3.2fALTER TABLE Ships ADD yard CHAR(30);Exercise 2.4.1aR1 := speed 3.00 (PC)R2 := model(R1)model100510061013Exercise 2.4.1bR1 := hd 100 (Laptop)R2 := Product (R1)R3 := maker (R2)makerEABFGExercise 2.4.1cR1 := maker=B (Product PC)R2 := maker=B (Product Laptop)R3 := maker=B (Product Printer)R4 :
13、= model,price (R1)R5 := model,price (R2)R6: = model,price (R3)R7 := R4 R5 R6modelprice100464910056301006104920071429Exercise 2.4.1dR1 := color = true AND type = laser (Printer)R2 := model (R1)model30033007Exercise 2.4.1eR1 := type=laptop (Product)R2 := type=PC(Product)R3 := maker(R1)R4 := maker(R2)R
14、5 := R3 R4makerFGExercise 2.4.1fR1 := PC1(PC)R2 := PC2(PC)R3 := R1 (PC1.hd = PC2.hd AND PC1.model PC2.model) R2R4 := hd(R3)hd25080160Exercise 2.4.1gR1 := PC1(PC)R2 := PC2(PC)R3 := R1 (PC1.speed = PC2.speed AND PC1.ram = PC2.ram AND PC1.model PC2.model) R2R4 := PC1.model,PC2.model(R3)PC1.modelPC2.mod
15、el10041012Exercise 2.4.1hR1 := model(speed 2.80(PC) model(speed 2.80(Laptop)R2 := maker,model(R1 Product)R3 := R3(maker2,model2)(R2)R4 := R2 (maker = maker2 AND model model2) R3R5 := maker(R4)makerBEExercise 2.4.1iR1 := model,speed(PC)R2 := model,speed(Laptop)R3 := R1 R2R4 := R4(model2,speed2)(R3)R5
16、 := model,speed (R3 (speed speed2 ) R4)R6 := R3 R5R7 := maker(R6 Product)makerBExercise 2.4.1jR1 := maker,speed(Product PC)R2 := R2(maker2,speed2)(R1)R3 := R3(maker3,speed3)(R1)R4 := R1 (maker = maker2 AND speed speed2) R2R5 := R4 (maker3 = maker AND speed3 speed2 AND speed3 speed) R3R6 := maker(R5)
17、makerADE Exercise 2.4.1kR1 := maker,model(Product PC)R2 := R2(maker2,model2)(R1)R3 := R3(maker3,model3)(R1)R4 := R4(maker4,model4)(R1)R5 := R1 (maker = maker2 AND model model2) R2R6 := R3 (maker3 = maker AND model3 model2 AND model3 model) R5R7 := R4 (maker4 = maker AND (model4=model OR model4=model
18、2 OR model4=model3) R6R8 := maker(R7)makerABDEExercise 2.4.2aExercise 2.4.2bExercise 2.4.2cExercise 2.4.2dExercise 2.4.2eExercise 2.4.2fExercise 2.4.2gExercise 2.4.2hExercise 2.4.2iExercise 2.4.2jExercise 2.4.2kExercise 2.4.3aR1 := bore 16 (Classes)R2 := class,country (R1)classcountryIowaUSANorth Ca
19、rolinaUSAYamatoJapanExercise 2.4.3bR1 := launched 1921 AND displacement 35000 (R1)R3 := name (R2)nameIowaMissouriMusashiNew JerseyNorth CarolinaWashingtonWisconsinYamatoExercise 2.4.3eR1 := battle=Guadalcanal(Outcomes)R2 := Ships (ship=name) R1R3 := Classes R2R4 := name,displacement,numGuns(R3)named
20、isplacementnumGunsKirishima320008Washington370009Exercise 2.4.3fR1 := name(Ships)R2 := ship(Outcomes)R3 := R3(name)(R2)R4 := R1 R3nameCaliforniaHarunaHieiIowaKirishimaKongoMissouriMusashiNew JerseyNorth CarolinaRamilliesRenownRepulseResolutionRevengeRoyal OakRoyal SovereignTennesseeWashingtonWiscons
21、inYamatoArizonaBismarckDuke of YorkFusoHoodKing George VPrince of WalesRodneyScharnhorstSouth DakotaWest VirginiaYamashiroExercise 2.4.3gFrom 2.3.2, assuming that every class has one ship named after the class.R1 := class(Classes)R2 := class(name class(Ships)R3 := R1 R2classBismarckExercise 2.4.3hR1
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 系统 基础教程 第二 答案 解析 19
限制150内