NTU-Exam 板


LINE

课程名称︰资料库系统 课程性质︰必修 课程教师︰朱浩华 开课学院:电资 开课系所︰资工 考试日期(年月日)︰2008 考试时限(分钟):180 是否需发放奖励金:是 (如未明确表示,则不予发放) 试题 : I here with state that I understand and will adhere to the following academic integrity: "I will not use or attempt to use any unauthorized assistance, material, or study aids in this midterm examination. If I violate academic integrity, I may receive a grade of 0." __________________________ Signature (2 points) PART A: ER Diagram (24 Points) (1) (12 points) In the space below, draw an E/R diagram that best represents the following scenario. Indicate keys, many-one relationships, weak entity sets, and other features of E/R diagrams covered in class, as appropriate. There are hospitals, with a name and address. Address is unique. There rooms in hospitals, with a room number. There are people, with a name and social-security number. Some people are doctors, and doctors have a specialty; some people are patients, and patients have an age. An operation involves a patient and a doctor, and takes place in a hospital room. And operation has a date and time. For full credit, do not make operations an entity set; rather, make it a relationship. (2) (12 points) Translate the above ER diagram into relational tables. Use SQL create_table commaned to define all the relational tables. PART B: Relational Algebra (20 Points) Consider the following four relations to store data about animals in a zoo: Animals(idNumber,type,cageNumber) TypeKeepers(name, type) CageKeepers(name,cageNumber) idNumber is a key for Animals, and cageNumber is a key for Cages. TypeKeepers lists people responsiible for caring for a particular type of animal, while CageKeepers lists people responsible for caring for a certain cage. For each of these two, both attributes from the key; i.e. it is possible for the same person to care for multiple types/cages, and it is possible for the same type/cage ro be cared for by several people. (1) (6 points) Consider the following sequence of relational algebra statement: Result = (Animals∞CageKeepers)∩(Animals∞Typekeepers) Given the following sets of data for each of the relations, show (in the space on the next page) the relation that will be stored into Result table (show the schema and all the tuples that will be in the relation). Animals idnumber tupe cageNumber 1 Zebra 10 2 Monkey 20 3 Monkey 10 4 Kangaroo 30 5 Zebra 40 6 Monkey 40 Cagekeepers TypeKeepers name cageNumber name Type Ann 10 Ann Zebra Chris 20 Bob Monkey Chris 30 Ann Kangaroo Bob 40 Chris Kangaroo Bob 10 (2) (6 points) State briefly in English what the query from (1) is asking. (3) (8 points) Write a relational algebra expression to find all pairs of animals of two different types in the same cage. For each pair of animal satisfying this requirement, your expression should return each animal's idNumber and type, as well as the cageNumber of the cage they are in. For example, if Animal 1 of type Zebra and Animal2 of type Monkey are both in cage 10, then the result of your expression should include a tuple (1,Zebra,2,Monkey,10) (the attribulte could be in a different order). The same animal pair should not apperr twice in your result. PART C: Query Equivalences (26 Points) Each row of the table below shows two queries. In the blank third column of the table write "YES" if the two queries are equivalent, and "NO" if they are not equivalent. Remember that two queries are equivalent if they always return exactly the same answer on all databases. All queries refer to relations R(A,B) and/or S(A,B). In both relations R and S, attribute A is a key and attribute B is not a key. No attributes are permitted to contain NULL values. Do not make any other assumptions about the data. To lessen the score for guessing, you will earn 3 points for each correct answer, -1 points for each incorrect answer, and 0 points for each answer left blank. PART D: SQL (16 Points) The relations below represent information about the 15 members of the UN Security Council and the resolutions (res) that they voted on. Members(coutry-name,status) Votes(res,country-name,vote) The status of a country is either 'permanent' or 'elected'. A vote can be either 'yes','no', or 'abstain'. (1) (8 points) In order for a resolution to pass, there must be at least 9 'yes' votes from among the 15 members of the council. In addition, there must be no veto; that is, none of the five permanent members of the council vote 'no' on that resolution. We wish to write a query to find the set of resolutions that passed. (2) (8 points) Write a query to list each permanent member of the council, along with the number of vetos('no' votes) they have cast. We must not forget to consider the possibility that a permanent member cast no vetos. PART E: More SQL(16 Points) (1) (8 points) Consier a SQL table T(A int). Assume there are no NULL values. Make no assumptions about keys. We execute the following SQL query: select sum(B) from T, (select distinct A, 1 as B from T) as T2 where T.A = T2.A and T2.A = 3 In one sentence, state in English what this query computes. The correct answer is simple and brief. (2) (8 points) Consider a SQL table T(A int, B int, C int). Assume there are no NULL values. Suppose the following SQL query always returns an empty result. select * from (select T1.A, T1.B, T2.C from T as T1, T as T2 where T1.A = T2.A) as T3 where (T3.A, T3.B, T3.C) not in (select * from T) Assuming we know nothing else about T, what does this behavior tell us about the table T? The correct answer is simple and brief. --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.30.97
1F:推 zack30106opz:!!! 11/09 15:43
2F:→ andy74139 :已收录至资讯系!! 11/09 23:29







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP