




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Exercise 2.2.1a For relation Accounts, the attributes are: acctNo, type, balance For relation Customers, the attributes are: firstName, lastName, idNo, account Exercise 2.2.1b For relation Accounts, the tuples are: (12345, savings, 12000), (23456, checking, 1000), (34567, savings, 25) For relation Customers, the tuples are: (Robbie, Banks, 901-222, 12345), (Lena, Hand, 805-333, 12345), (Lena, Hand, 805-333, 23456) Exercise 2.2.1c For relation Accounts and the first tuple, the components are: 123456 acctNo savings type 12000 balance For relation Customers and the first tuple, the components are: Robbie firstName Banks lastName 901-222 idNo 12345 account Exercise 2.2.1d For relation Accounts, a relation schema is: Accounts(acctNo, type, balance) For relation Customers, a relation schema is: Customers(fi rstName, lastName, idNo, account) Exercise 2.2.1e An example database schema is: Accounts ( acctNo, type, balance ) Customers ( firstName, lastName, idNo, account ) Exercise 2.2.1f A suitable domain for each attribute: acctNo Integer type String balance Integer firstName String lastName String idNo String (because there is a hyphen we cannot use Integer) account Integer Exercise 2.2.1g Another equivalent way to present the Account relation: acctNo balance type 34567 25 savings 23456 1000 checking 12345 12000 savings Another equivalent way to present the Customers relation: idNo firstName lastName account 805-333 Lena Hand 23456 805-333 Lena Hand 12345 901-222 Robbie Banks 12345 Exercise 2.2.2 Examples of attributes that are created for primarily serving 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 Identi fication Numbers (VIN), a unique serial number used by the automotive industry to identif y vehicles. Exercise 2.2.3a We 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.3b We can order the three tuples in any of 5! = 120 ways. Also, the columns can be ordered in any of 4! = 24 ways. Thus, the number of presentations is 120*24 = 2880 Exercise 2.2.3c We 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.1a CREATE TA BLE Product ( maker CHAR(30), model CHAR(10) PRIMARY KEY, type CHAR(15) ); Exercise 2.3.1b CREATE TA BLE PC ( model CHAR(30), speed DECIMAL(4,2), ram INTEGER, hd INTEGER, price DECIMAL(7,2) ); Exercise 2.3.1c CREATE TA BLE Laptop ( model CHAR(30), speed DECIMAL(4,2), ram INTEGER, hd INTEGER, screen DECIMAL(3,1), price DECIMAL(7,2) ); Exercise 2.3.1d CREATE TA BLE Printer ( model CHAR(30), color BOOLEAN, type CHAR (10), price DECIMAL(7,2) ); Exercise 2.3.1e ALTER TABLE Printer DROP color; Exercise 2.3.1f ALTER TABLE Laptop ADD od CHAR (10) DEFAULT ,none?; Exercise 2.3.2a CREATE TA BLE Classes ( class CHAR(20), type CHAR(5), country CHAR(20), numGuns INTEGER, bore DECIMAL(3,1), displacement INTEGER ); Exercise 2.3.2b CREATE TA BLE Ships ( name CHAR(30), class CHAR(20), launched INTEGER ); Exercise 2.3.2c CREATE TA BLE Battles ( name CHAR(30), date DATE ); Exercise 2.3.2d CREATE TA BLE Outcomes ( ship CHAR(30), battle CHAR(30), result CHAR(10) ); Exercise 2.3.2e ALTER TABLE Classes DROP bore; Exercise 2.3.2f ALTER TABLE Ships ADD yard CHAR(30); Exercise 2.4.1a R1 := speed 3.00 (PC) R2 := model(R1) Exercise 2.4.1b R1 := hd 100 (Laptop) R2 := Product (R1) model 1005 1006 1013 R3 := maker (R2) Exercise 2.4.1c R1 := maker=B (Product PC) R2 := maker=B (Product Laptop) R3 := maker=B (Product Printer) R4 := model,price (R1) R5 := model,price (R2) R6: = model,price (R3) R7 := R4 R5 R6 model price 1004 649 1005 630 1006 1049 2007 1429 Exercise 2.4.1d R1 := color = true AND type = la ser (Printer) R2 := model (R1) Exercise 2.4.1e R1 := type=laptop (Product) R2 := type=PC(Product) R3 := maker(R1) R4 := maker(R2) R5 := R3 R4 Exercise 2.4.1f R1 := P C1(PC) R2 := P C2(PC) R3 := R1 (PC1.hd = P C2.hd AND PC1.m odel PC2.model) R2 R4 := hd(R3) Exercise 2.4.1g R1 := P C1(PC) R2 := P C2(PC) R3 := R1 (PC1.speed = PC2.speed AND PC1.ram = PC2.ram AND PC1.m odel 35000 (R1) R3 := name (R2) name Iowa Missouri Musashi New Jersey North Carolina Washington Wisconsin Yamato Exercise 2.4.3e R1 := battle=Guadalcanal(Outcomes) R2 := Ships (shi p=name) R1 R3 := Classes R2 R4 := name,displacement,numG uns(R3) name displacementnumGuns Kirishima 32000 8 Washington 37000 9 Exercise 2.4.3f R1 := name(Ships) R2 := shi p(Outcomes) R3 := R3(name)(R2) R4 := R1 R3 name Californi a Haruna Hiei Iowa Kirishima Kongo Missouri Musashi New Jersey North Carolina Ramillies Renown Repulse Resolution Revenge Royal Oak Royal Sovereign Tennessee Washington Exercise 2.4.3g From 2.3.2, assuming that every class has one ship named af ter the class. R1 := class(Classes) R2 := class( name class(Ships) R3 := R1 R2 Exercise 2.4.3h R1 := c ountry( type =bb(Classes) R2 := c ountry( type =bc(Classes) R3 := R1 R2 Exercise 2.4.3i R1 := shi p,result ,date(Battles (battle= name) Outcomes) R2 := R2(ship2,result2,date2)(R1) R3 := R1 (ship=ship2 AND result=damaged AND date 35000 name Exercise 2.4.4e battle=Guadalcanal Outcomes Ships Classes (ship=name) name,displacement,numGuns Exercise 2.4.4f Ships Outcomes name ship R3(name) Exercise 2.4.4g Classes Ships class name class class Exercise 2.4.4h ClassesClasses type=bbtype=bc countrycountry Exercise 2.4.4i BattlesOutcomes (battle=name) ship,result,date R2(ship2,result2,date2) (ship=ship2 AND result=damaged AND date 16(Classes) = ? The Yamato class violates the constraint. Exercise 2.5.2b class( numGuns 9 A ND bore 14(Classes) = ? No violations to the constraint. Exercise 2.5.2c This complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R5 that stand for nodes of expression trees. Here is the sequence: R1(class,name) := class,name(Classes Ships) R2(class2,name2) := R2(class2,name2)(R1) R3(class3,name3) := R3(class3,name3)(R1) R4(class,name,class2,name2) := R1 (class = class2 AND name name2) R2 R5(class,name,class2,name2,class3,name3) := R4 (class=class3 AND name name 3 AND name2 name3) R3 The constraint is R5 = ? The Kongo, Iowa and Revenge classes violate the constraint. Exercise 2.5.2d country( type = bb(Classes) countr y( type = bc(Classes) = ? Japan and Gt. Britain violate the constraint. Exercise 2.5.2e This complex expression is best seen as a sequence of steps in which we define temporary relations R1 through R5 that stand for nodes of expression trees. Here is the sequence: R1(ship,battle,result,class) := ship,battle,result,class(Outcomes (shi p = name) Ships) R2(ship,battle,result,numGuns) := ship,battle,result,numG uns(R1 Classes)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 网格化系统汇报
- 芯片技术提取颜色
- 小红书内容制作实战课程
- 新思想纲要解读
- 三甲医院妇产科进修汇报
- 皮肤科常用药物
- 小学信息技术融合实践路径
- 洋葱的植物细胞结构解析
- 星空露营节活动方案
- 部编版九年级下册历史第一单元复习课件
- 自然灾害信息员业务知识考核试题
- 房产租赁合同文本与房产租赁合同模板
- 2022年临沧市市级单位遴选(选调)笔试试题及答案
- 重庆市沙坪坝区人民医院消防安全整改工程施工方案
- 施工组织设计施工总体部署完整版
- 天津电网规划设计技术原则
- YY 0054-2010血液透析设备
- LY/T 2383-2014结构用木材强度等级
- GB/T 8017-2012石油产品蒸气压的测定雷德法
- GB/T 528-2009硫化橡胶或热塑性橡胶拉伸应力应变性能的测定
- 2023年江苏省中学生生物学竞赛(奥赛)初赛试题和答案
评论
0/150
提交评论