完整版数据库系统基础教程第二章答案.docx
《完整版数据库系统基础教程第二章答案.docx》由会员分享,可在线阅读,更多相关《完整版数据库系统基础教程第二章答案.docx(23页珍藏版)》请在冰豆网上搜索。
![完整版数据库系统基础教程第二章答案.docx](https://file1.bdocx.com/fileroot1/2022-10/20/a41c03ef-edd5-4531-a11b-24a2adfd3577/a41c03ef-edd5-4531-a11b-24a2adfd35771.gif)
完整版数据库系统基础教程第二章答案
Exercise2.2.1a
ForrelationAccounts,theattributesare:
acctNo,type,balance
ForrelationCustomers,theattributesare:
firstName,lastName,idNo,account
Exercise2.2.1b
ForrelationAccounts,thetuplesare:
(12345,savings,12000),
(23456,checking,1000),
(34567,savings,25)
ForrelationCustomers,thetuplesare:
(Robbie,Banks,901-222,12345),
(Lena,Hand,805-333,12345),
(Lena,Hand,805-333,23456)
Exercise2.2.1c
ForrelationAccountsandthefirsttuple,thecomponentsare:
123456acctNo
savingstype
12000balance
ForrelationCustomersandthefirsttuple,thecomponentsare:
RobbiefirstName
BankslastName
901-222idNo
12345account
Exercise2.2.1d
ForrelationAccounts,arelationschemais:
Accounts(acctNo,type,balance)
ForrelationCustomers,arelationschemais:
Customers(firstName,lastName,idNo,account)
Exercise2.2.1e
Anexampledatabaseschemais:
Accounts(
acctNo,
type,balance
)
Customers(
firstName,
lastName,
idNo,account
)
Exercise2.2.1f
Asuitabledomainforeachattribute:
acctNoInteger
typeString
balanceIntegerfirstNameStringlastNameString
idNoString(becausethereisahyphenwecannotuseInteger)accountInteger
Exercise2.2.1g
AnotherequivalentwaytopresenttheAccountrelation:
acctNo
balance
type
34567
P25-
savings
23456
p1000
checking
12345
12000
savings
AnotherequivalentwaytopresenttheCustomersrelation:
idNo
firstName
lastName
account
805-333
Lena
Hand
23456
805-333
Lena
Hand
12345
901-222
Robbie
Banks
12345
Exercise2.2.2
Examplesofattributesthatarecreatedforprimarilyservingaskeysinarelation:
UniversalProductCode(UPC)usedwidelyinUnitedStatesandCanadatotrackproductsinstores.
SerialNumbersonawidevarietyofproductstoallowthemanufacturertoindividuallytrackeachproduct.
VehicleIdentificationNumbers(VIN),auniqueserialnumberusedbytheautomotiveindustrytoidentifyvehicles.
Exercise2.2.3a
Wecanorderthethreetuplesinanyof3!
=6ways.Also,thecolumnscanbeorderedinanyof3!
=6ways.Thus,thenumberofpresentationsis6*6=36.
Exercise2.2.3b
Wecanorderthethreetuplesinanyof5!
=120ways.Also,thecolumnscanbeorderedinanyof4!
=24ways.Thus,thenumberofpresentationsis120*24=2880
Exercise2.2.3c
Wecanorderthethreetuplesinanyofm!
ways.Also,thecolumnscanbeorderedinanyofn!
ways.Thus,thenumberofpresentationsisn!
m!
Exercise2.3.1a
CREATETABLEProduct(
makerCHAR(30),
modelCHAR(10)PRIMARYKEY,
typeCHAR(15)
);
Exercise2.3.1b
CREATETABLEPC(
modelCHAR(30),
speedDECIMAL(4,2),
ramINTEGER,
hdINTEGER,
priceDECIMAL(7,2)
);
Exercise2.3.1c
CREATETABLELaptop(
modelCHAR(30),
speedDECIMAL(4,2),
ramINTEGER,
hdINTEGER,
screenDECIMAL(3,1),
priceDECIMAL(7,2)
);
Exercise2.3.1d
CREATETABLEPrinter(
modelCHAR(30),colorBOOLEAN,typeCHAR(10),priceDECIMAL(7,2)
);
Exercise2.3.1e
ALTERTABLEPrinterDROPcolor;
Exercise2.3.1f
ALTERTABLELaptopADDodCHAR(10)DEFAULT'none'
Exercise2.3.2a
CREATETABLEClasses(
classCHAR(20),typeCHAR(5),countryCHAR(20),numGunsINTEGER,boreDECIMAL(3,1),displacementINTEGER
);
Exercise2.3.2b
CREATETABLEShips(
nameCHAR(30),
classCHAR(20),launchedINTEGER
);
Exercise2.3.2c
CREATETABLEBattles(
nameCHAR(30),
dateDATE
);
Exercise2.3.2d
CREATETABLEOutcomes(
shipCHAR(30),battleCHAR(30),resultCHAR(10)
);
Exercise2.3.2e
ALTERTABLEClassesDROPbore;
Exercise2.3.2f
ALTERTABLEShipsADDyardCHAR(30);
Exercise2.4.1a
R1:
=spfeed>3•妒C)
R2:
=nwdei(RI)
R1:
=h10((Laptop)
R2:
=Product「汇丨(R1)
R3:
=nmaker(R2)
Exercise2.4.1c
R1:
=maker=B(Product1PC)
R2:
=maker=B(Product1Laptop)
R3:
=maker=B(Product匚:
:
.Printer)
R4:
=nd,price(R1
R5:
=nd,price(R2
R6:
=mSdeprice(R3
R7:
=R4R5、丿R6
model
price
1004
649
1005
630
1006
1049
2007
1429
Exercise2.4.1d
R1:
=color=trueANDtype=laser(Printer)R2:
=ndel(R1)model
3003
3007-
Exercise2.4.1e
R1:
=type=iaptop(Product)
R2:
=type=Pc(Product)
R3:
=mnker(R1)
R4:
=nmaker(R2)
R5:
=R3-R4
maker
F
G
Exercise2.4.1f
R1:
=pCi(PC)
R2:
=PC2(PC)
R3:
=R1匸:
二I(PCI.hd=PC2.hdANDPCI.model<>PC2.model)R2
R4:
=hd(R3)
Exercise2.4.1g
R1:
=pci(PC)
R2:
=pc2(PC)
R3:
=R1-(PCI.speed=PC2.speedANDPCI.ram=PC2.ramANDPCI.modelR4:
=PC1model,PC2.model(R3)
PC1.model
PC2.model
1004
1012
Exercise2.4.1h
nmodel(Epeed>2.8PC))nnker,modelProduct)
p(maker2,model2)(R2)
R3
Exercise2.4.1k
Exercise2.4.2a
Ttnodel
PC
R4:
=R2,■-'■■(maker=maker?
ANDmodel<>model2)
R5:
=nker(R4)
maker
B
E
Exercise2.4.1i
R1
=rrndel,speed(PC)
R2
=rndel,speed(Laptop)
R3
=R1UR2
R4
=P(model2,speed2)(R3)
R5
=mndel,speed(R3(s