Database, Spring, 2005
Course No.: CS3010302
Instructor: 鮑興國 Ph.D.
National Taiwan University of Science and Technology
New:
Final June 11, 14:00 IB-601
Instructor: Hsing-Kuo Pao 鮑興國 , 第四教學大樓 T4-505 , 2730-1065
Lectures time: Mon. 8:30-10:20, Thu. 9:30-10:20
location: IB-701
Teaching Assistants:
Textbook:
Database – system concepts (4th ed.) by Silberschatz, Korth, Sudarshan, 2002
Fundamentals of Database Systems (4th ed.) by Elmasri & Navathe, 2004
Grading:
midterm (30%), final (40%) 6 (1 per 2~3 weeks) homework (30%)
1 programming hw at most!
Course page: http://140.118.155.153/~web/teach/db2005.htm
Slides in the Class
Ch2. Entity-Relationship Model
Ch7. Relational-Database Design
Homework 1
Homework 2
Due: Apr. 21
1. We have a DBMS for student course offering. There are relations in the database (keys are with underscore): Course(c#, title, credits, year, time, room), Instructor(dept, iid#, name), Student(dept, sid#, name), Enrols(sid#, c#, grade), Teaches(iid#, c#), TAs(sid#, c#). Please write down the answer for the following questions, each by (1) relational algebra, (2) tuple relational calculus, (3) SQL.
You may write the relations with the abbreviations: C(c#, t, cd, y, tm, r), I(d, iid#, n), S(d, sid#, n), E(sid#, c#, g), T(iid#, c#), TA(sid#, c#). Some principles: students can take many courses, and can be TAs in many courses. Professors can be instructors in many courses. You can assume all keys are unique, and course titles are unique.
(a) Find all courses(including all information) offered in 2005.
(b) Find all students’ names in the course “Database”.
(c) Find all people’s names (including teachers and students) in the department “CS”.
(d) Find all people’s names who are students, but not TAs. For SQL, please list your answer by department.
(e) Find all courses’ titles which are taught by more than one (>1) teacher. (by SQL only)
(f) Find John’s course no. which he has grade above 80 (included).
(g) Find all students (sid#) who have average grades above 70 (included). (by SQL only)
(h) Find the students (names) who take all courses offered in 2005.
2. p.129, 3.13
3. p.185, 4.4.
Homework 3
Final Project
Login Server使用說明
1. Asnwer to textbook page 153
In textbook page 153:
select distinct S.customer-name
from depositor as S
where not exists ((select branch-name
from branch
where branch-city = 'Brooklyn')
except
(select R.branch-name
from depositor as T, account as R
where T.account-number = R.account-number and
S.customer-name = T.customer-name))
cannot be changed to
select distinct S.customer-name
from depositor as S
where not exists ((select branch-name
from branch
where branch-city = 'Brooklyn')
except
(select R.branch-name
from account as R
where S.account-number = R.account-number))
In the second one, for each depositor S, a check of account number equality is done; i.e.,
selecting all R's where S.account-number = R.account-number for a given depositor S.
Clearly, it is not what we want. We want to collect all accounts for a given name.
(Revised in Jun 10)