0% found this document useful (0 votes)
53 views2 pages

Relational Model: Exercises

This document contains exercises and answers related to relational database modeling and queries. It defines sample relations for a university database including students, courses, enrollments, instructors, and course requirements. It also provides solutions for relational algebra queries on these relations and discusses concepts like outer joins, updates involving multiple relations, and inserting tuples into views.

Uploaded by

sansayana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views2 pages

Relational Model: Exercises

This document contains exercises and answers related to relational database modeling and queries. It defines sample relations for a university database including students, courses, enrollments, instructors, and course requirements. It also provides solutions for relational algebra queries on these relations and discusses concepts like outer joins, updates involving multiple relations, and inserting tuples into views.

Uploaded by

sansayana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C H A P T E R

Relational Model

Exercises
3.1 Answer: One solution is described below. Many alternatives are possible. Underlined attributes indicate the primary key. student (student-id, name, program) course (courseno, title, syllabus, credits) course-offering (courseno, secno, year, semester, time, room) instructor (instructor-id, name, dept, title) enrols (student-id, courseno, secno, semester, year, grade) teaches (courseno, secno, semester, year, instructor-id) requires (maincourse, prerequisite) 3.5 Answer: e. person-name ((employee manages) (manager-name = employee2.person-name employee.street = employee2.street employee.city = employee2.city) (employee2 (employee))) f. The following solutions assume that all people work for exactly one company. If one allows people to appear in the database (e.g. in employee) but not appear in works, the problem is more complicated. We give solutions for this more realistic case later. person-name (company-name = First Bank Corporation (works)) If people may not work for any company: person-name (employee) person-name ((company-name = First Bank Corporation) (works)) g. person-name (works) (works.person-name (works works2 (works)))

(works.salary works2.salary works2.company-name = Small Bank Corporation)


15

16

Chapter 3

Relational Model

3.7 Answer:

a. The left outer theta join of r(R) and s(S) (r s) can be dened as (r s) ((r R (r s)) (null, null, . . . , null)) The tuple of nulls is of size equal to the number of attributes in S. c. The update syntax allows reference to a single relation only. Since this update requires access to both the relation to be updated (works) and the manages relation, we must use several steps. First we identify the tuples of works to be updated and store them in a temporary relation (t1 ). Then we create a temporary relation containing the new tuples (t2 ). Finally, we delete the tuples in t1 , from works and insert the tuples of t2 . t1 works.person-name,company-name,salary (works.person-name=manager-name (works manages)) t2 person-name,company-name,1.1salary (t1 ) works (works t1 ) t2

3.8 Answer:

3.13 Answer: a. {t | q r (q[A] = t[A])} b. {t | t r t[B] = 17} c. {t | p r q s (t[A] = p[A] t[B] = p[B] t[C] = p[C] t[D] = q[D] t[E] = q[E] t[F ] = q[F ])} d. {t | p r q s (t[A] = p[A] t[F ] = q[F ] p[C] = q[D]} 3.14 Answer: a. b. c. d. e. f. {< t > | p, q (< t, p, q > r1 )} {< a, b, c > | < a, b, c > r1 b = 17} {< a, b, c > | < a, b, c > r1 < a, b, c > r2 } {< a, b, c > | < a, b, c > r1 < a, b, c > r2 } {< a, b, c > | < a, b, c > r1 < a, b, c > r2 } {< a, b, c > | p, q (< a, b, p > r1 < q, b, c > r2 )}

3.19 Answer: To insert the tuple (Johnson, 1900) into the view loan-info, we can do the following:borrower (Johnson, k ) borrower loan (k , , 1900) loan such that k is a new marked null not already existing in the database. Note: no commercial database system supports marked nulls, but strings (or other values) that cannot possibly occur as real values can be used to simulate marked nulls.

You might also like