Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Relational Database -Introduction to Database Systems - Exams, Exams of Introduction to Database Management Systems

Main points of this past exam are: Relational Database, Integrity Constraints, Definition, Largest Number, Students, Equivalent Query, Base Tables, Underlying Base Tables, Modified, Associated Stored Procedures

Typology: Exams

2012/2013

Uploaded on 04/02/2013

shalin_p01ic
shalin_p01ic 🇮🇳

4

(7)

86 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 186
MIDTERM
FALL 1994
There are 9 questions to this exam. All count equally.
Queries expressed in relational algebra and relational calculus must follow
the syntax used in class. Queries expreseed in SQL must follow the syntax
used in class or in the INGRES Manual. All SQL queries should contain NO
duplicates in their outputs. It is not necessary to sort the outputs in any
order.
You are not allowed to use views for any questions expect question 7.
Use the following relational database schema for all the questions except
question 1:
DEPT (dname, location)
STUDENT (name, regno, gpa, level, dept)
COURSE (cno, cname, dept)
TAKE (regno, cno)
None of the columns can have null values.
Problem #1
Suppose there are two relations A (a1, a2, a3) and B (b1, b2, b3). A has two candidate keys and its primary
key is (a1, a2). B has only one candidate key and its primary key is (b2, b3). How many candidate keys will
the relation A times B have? How many primary keys will the relation A times B have? Please state your
reasoning in support of your conclusion.
Problem #2
Express in relational algebra the names of the EECS students who are taking any EECS courses.
Problem #3
Express in relational calculus the names of the departments which either have no students or have at least one
student taking each EECS course.
CS 186, MIDTERM, FALL 1994
CS 186MIDTERMFALL 1994professor (e.g., Professor J. Wawrzynek) 1
pf3

Partial preview of the text

Download Relational Database -Introduction to Database Systems - Exams and more Exams Introduction to Database Management Systems in PDF only on Docsity!

CS 186

MIDTERM

FALL 1994

There are 9 questions to this exam. All count equally.

Queries expressed in relational algebra and relational calculus must follow

the syntax used in class. Queries expreseed in SQL must follow the syntax

used in class or in the INGRES Manual. All SQL queries should contain NO

duplicates in their outputs. It is not necessary to sort the outputs in any

order.

You are not allowed to use views for any questions expect question 7.

Use the following relational database schema for all the questions except

question 1:

DEPT (dname, location)

STUDENT (name, regno, gpa, level, dept)

COURSE (cno, cname, dept)

TAKE (regno, cno)

None of the columns can have null values.

Problem

Suppose there are two relations A (a1, a2, a3) and B (b1, b2, b3). A has two candidate keys and its primary key is (a1, a2). B has only one candidate key and its primary key is (b2, b3). How many candidate keys will the relation A times B have? How many primary keys will the relation A times B have? Please state your reasoning in support of your conclusion.

Problem

Express in relational algebra the names of the EECS students who are taking any EECS courses.

Problem

Express in relational calculus the names of the departments which either have no students or have at least one student taking each EECS course.

CS 186MIDTERMFALL 1994professor (e.g., Professor J. Wawrzynek) 1

Problem

Express in SQL the names and department names of the students who are from departments not located in Evans Hall.

Problem

Express in SQL the names of the students who are not taking any EECS courses.

Problem

Express in SQL the names of the departments which have the largest number of students taking EECS courses.

Problem

Suppose we have the following view definition in the database for all CS students:

create view cs_student as select s.name, s.regno, s.gpa, s.level from STUDENT s where s.dept = 'CS'

Suppose we have the following INGRES table level integrity constraints: create integrity on STUDENT is gpa > 0

Usually the DBMS query modifier converts a query involving views into an equivalent query on the underlying base tables. The query is then modified according to the table level integrity constraints existing on the base tables.

Modify the following query according to the view definition and table level integrity constraint defined above: update cs_student set gpa = gpa - 1. where level = 4

Problem

Write the rules (and the associated stored procedures) to enforce the integrity constraint: No students can take more than 3 courses from the same department. You may assume that the department of a course will nver change.

Problem #4 2