0% found this document useful (0 votes)
4 views6 pages

4347sample Exam1

Uploaded by

meylicolmenero
Copyright
© © All Rights Reserved
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)
4 views6 pages

4347sample Exam1

Uploaded by

meylicolmenero
Copyright
© © All Rights Reserved
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/ 6

CS4347 Database Systems

Sample Exam-I Questions

Multiple choice questions

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

Use the following table for questions 3 through 5.


EMPLOYEE
EmpNo EmpName Department Salary
101 James Accounting 100
105 Sally Finance 300
107 Tim Accounting 100
112 Ana Finance null
3. What will be the result of the following query?
select count(salary)
from Employee
A.) 1 B.) 2 C.) 3 D.) We cannot know E.) None
Answer: C

1
4. What will be the result of the following query?
select Department, sum(salary)
from Employee
group by Department

A.) Accounting 200


Finance 300
B.) Accounting 200
Finance null
C.) Accounting 300
Finance 200
D.) None

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?

A.) CREATE TABLE Students (


sid CHAR(20) NOT NULL,
name CHAR(20),
login CHAR(10),
age INTEGER,
gpa REAL
PRIMARY KEY(sid)
FOREIGN KEY(sid) REFERENCES Enrolled(sid)
ON DELETE CASCADE
ON UPDATE CASCADE));

CREATE TABLE Enrolled (


sid CHAR(20),
cid CHAR(20),
grade CHAR(2),
PRIMARY KEY (sid,cid));

B.) CREATE TABLE Students (


sid CHAR(20) NOT NULL,
name CHAR(20),
login CHAR(10),
age INTEGER,
gpa REAL
PRIMARY KEY(sid));

CREATE TABLE Enrolled (


sid CHAR(20),
cid CHAR(20),
grade CHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY(sid) REFERENCES Students(sid)
ON DELETE CASCADE
ON UPDATE CASCADE);

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);

-- Populate data into the ENROLLED table


INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, 'Carnatic101', 'C');
INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, 'Reggae203', 'B');
INSERT INTO Enrolled (sid, cid, grade) VALUES (53650, 'Topology112', 'A');
INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, 'History105', 'B');

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);

-- Populate data into the ENROLLED table


INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, “Carnatic101”, “C”;
INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, “Reggae203”, “B”);
INSERT INTO Enrolled (sid, cid, grade) VALUES (53650, “Topology112”, “A”);
INSERT INTO Enrolled (sid, cid, grade) VALUES (53666, “History105”, “B”);

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:

STUDENT PROFESSOR PROF_MAJOR


SNo SName PNo Major PNo Major Year
S1 Tim P1 MATH PNo PName
P1 MATH 2013
S2 Daniel P1 BIO P1 Brad
P2 PHIL 2012
S3 Samantha P2 PHIL P2 Paul P2 ART 2012
S3 Samantha P2 ART P3 Casey P3 2013
S4 Kelly P4 Daniel P5 JAZZ 2013

The following constraints are also defined:


• SNo is the PK of the STUDENT table.
• PNo is the PK of the PROFESSOR table.
• (PNo, Major) is the PK of the PROF_MAJOR table.
• PNo attribute of PROF_MAJOR is a FK referencing the PROFESSOR table.
• (PNo, Major) of STUDENT is a FK referencing the PROF_MAJOR table.

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.

You might also like