4347sample Exam1
4347sample Exam1
1. Which of the following is not among the tasks of a database management system?
A.) Construct
B.) Manipulate
C.) Define
D.) Share
E.) All of the above are among the tasks of a database management system
Answer: E
2. Which of the following is not among the reasons why the value of an attribute is null?
A.) attribute does not apply to this tuple
B.) value exists but unavailable
C.) value belongs to a composite attribute
D.) value withheld
E.) value unknown
Answer: C
1
4. What will be the result of the following query?
select Department, sum(salary)
from Employee
group by Department
Answer: A
5. Which of the following is the correct SQL statement for the query: “List the names of the employees
who work for the Finance department and earn more than 200K”
I. II.
Select EmpName Select EmpName
From Employee From Employee
Where Department = 'Finance' Where Department is 'Finance'
and Salary > 200 and Salary > 200
A.) Only I
B.) Only II
C.) I and II
D.) none
Answer: A
Use the following tables as STUDENTS and ENROLLED to answer the questions 6 and 7:
STUDENTS.sid: PK
ENROLLED.{sid, cid}: PK
ENROLLED.sid is a FK that references STUDENTS.sid
STUDENTS ENROLLED
sid name login age gpa sid cid grade
53650 Smith smith@math 19 3.8 53650 Topology112 A
53666 Carnatic101 C
53666 Jones jones@cs 18 3.4
53666 History105 B
53688 Smith smith@eecs 18 3.2 53666 Reggae203 B
2
6. Assume that when a tuple is removed from the STUDENTS table, the related tuple is automatically
deleted from the ENROLLED table.
Which of the following SQL statements correctly create the STUDENTS and ENROLLED tables?
C.) We cannot know since we need to collect more information to create those tables.
D.) None
Answer: B
3
7. Which of the following SQL statements correctly populate these tables with the given data in the
relational database states above.
A.) We cannot populate those tables as the referential integrity constraint is invalid.
B.) We need to create a GRADES table before proceeding with populating STUDENTS and ENROLLED tables
with data.
C.)
-- Populate data into the STUDENTS table
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53666, 'Jones', 'jones@cs', 18, 3.4);
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53688, 'Smith', 'smith@eecs', 18, 3.2);
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53650, 'Smith', 'smith@math', 19, 3.8);
D.)
-- Populate data into the STUDENTS table
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53666, “Jones”, “jones@cs”, 18, 3.4);
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53688, “Smith”, “smith@eecs”, 18, 3.2);
INSERT INTO Students (sid, name, login, age, gpa) VALUES (53650, “Smith”, “smith@math”, 19, 3.8);
Answer: C
T/F questions
8. In relational model, the degree of a relation is defined as the number of tuples of a relation.
.… False ……
9. In referential integrity constraint, tuples in the referencing relation R1 have attributes FK (called foreign
key attributes) that reference the primary key attributes PK of the referenced relation R2.
.… True ……
4
Use the following 3 tables as STUDENT, PROFESSOR, and PROF_MAJOR for questions 10 through 13:
10. In STUDENT table, the third and fourth tuples have identical Sno value. This is a key violation: the value
of a key attribute in the new tuple already exists in another tuple in the relation.
.… True ……
11. In STUDENT table, Major of the second tuple is BIO, which is inconsistent with the referenced table
PROF_MAJOR. It should be PHIL instead.
Referential integrity violation: A tuple with P1 as PNo and BIO as Major does not exist in the referenced
table PROF_MAJOR.
.… True ……
12. In PROF_MAJOR table, Major of the fourth record is null. This is referential integrity constraint violation.
.… False ……
Entity integrity violation: The whole PK or any component of PK must not be null.
13. In PROF_MAJOR table, the fifth tuple has P5 as the PNo. This is key violation.
.… False ……
Referential integrity violation: A tuple with P5 as PNo does not exist in the referenced table PROFESSOR.
5
Matching question:
Match the following terms with the corresponding definitions. For example, if term # 1 is defined in row n,
then put 1 in row n.
Example: You decide which number to put into the “Answer” column below.
YOU WILL BE REQUIRED TO ALSO DO THIS IN THE ACTUAL EXAM: Then copy the “Answer”
column entries to the front page under the “Answers” column in the same order as they
appear here.
Term Definition
1 Java 3 A kitchen item for cooking.
2 Air 1 A programming language.
3 Pan 2 The substance we need to breathe.
Term Definition
1 Primary key 3 maximum number of relationship instances that
entity can participate in.
2 Entity integrity constraint 1 A minimal superkey of a relation R.
3 Cardinality ratio 2 No primary key value can be null.
4 Assertion 5 a single virtual table derived from other tables.
5 View 4 Specify additional types of constraints outside the
scope of built-in relational model constraints.