n
n
n
n



Database, Spring, 2005

Course No.: CS3010302

Instructor: 鮑興國 Ph.D.

National Taiwan University of Science and Technology

 

New:

Final June 11, 14:00 IB-601

 Solution to Homework 2

Answer to page 153

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:

Grading:

Course page: http://140.118.155.153/~web/teach/db2005.htm

 

 

Slides in the Class

Ch1. Introduction

Ch2. Entity-Relationship Model

Ch3. Relational Model

Ch4. SQL

Ch7. Relational-Database Design

Ch10. XML

Ch15. Transactions

Ch16. Concurrency Control

 

Homework

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.

(suggested solution)

Homework 3

Final Project

Login Server使用說明

(Test Data)

 

Misc

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)