You are on page 1of 4

Mandalay Technological University

Department of Computer Engineering and Information Technology


IT- 31035 Database Management System I
Tutorial – III
Date : 27.2.2020 Time allowed 1 hour
Attempt All Question
I. Choose the correct answer for each question. (8 Marks)
(1). Which SQL command would you use to define the primary key for a new table called
'Employee' with the primary column to be 'empid'?
A: ADD TABLE Employee ADD PRIMARY KEY (empid)
B: ATTACH TABLE Employee ADD PRIMARY KEY (empid)
C: ADD TABLE Employee ATTACH PRIMARY KEY (empid)
D: ALTER TABLE Employee ADD PRIMARY KEY (empid)
(2). To change the value of a customer’s discount from 3 to 5, what command do we need to use:
A. INSERT C. DELETE
B. UPDATE D. SELECT
(3). Which SQL keyword is used to sort the result?
A. ORDER C. SORT
B. SORT-ORDER D. ORDER BY
(4). SQL keyword used to specify the table (s) to be used?
A. EXISTS C. SELECT
B. FROM D. SET
(5). Which SQL keyword must be used to remove duplicate rows from the result relation?
A. DELETE C. DISTINCT
B. UNIQUE D. NOT EXISTS
(6). The language associated with a database management system that is employed by end users and
programmers to manipulate data in the database is the:
A. data definition language C. data presentation language
B. Data manipulation language D. data translation language
(7). Three DDL commands:
A. CREATE, ALTER, DELETE C. INSERT, UPDATE, DELETE
B. CREATE, UPDATE, DROP D. CREATE, ALTER, DROP
(8). SQL keyword used to state the condition that specifies which rows are to be selected?
A. EXISTS C. SET
B. FROM D. SELECT
II. Specify the following queries in SQL on the COMPANY relational database schema shown in Figure
3.5. Show the result of each query if it is applied to the COMPANY database in Figure 3.6. (12 Marks)

(1) For every project located in ‘Stafford’, list the project number, the controlling department
number, and the department manager’s last name, address, and birth date.

(2) Retrieve all employees whose address is in Houston, Texas.

(3) Retrieve a list of employees and the projects they are working on, ordered by department and,
within each department, ordered alphabetically by last name, then first name.

------------- End of Question ---------------


Mandalay Technological University
Department of Computer Engineering and Information Technology
IT- 31035 Database Management System I
Tutorial – I
Date : 23.1.2020 Time allowed 1 hour
Questions & Solutions
I. Choose the correct answer for each question. (8 Marks)
(1). Which SQL command would you use to define the primary key for a new table called
'Employee' with the primary column to be 'empid'?
A: ADD TABLE Employee ADD PRIMARY KEY (empid)
B: ATTACH TABLE Employee ADD PRIMARY KEY (empid)
C: ADD TABLE Employee ATTACH PRIMARY KEY (empid)
D: ALTER TABLE Employee ADD PRIMARY KEY (empid) *
(2). To change the value of a customer’s discount from 3 to 5, what command do we need to use:
C. INSERT C. DELETE
D. UPDATE * D. SELECT
(3). Which SQL keyword is used to sort the result?
C. ORDER C. SORT
D. SORT-ORDER D. ORDER BY *
(4). SQL keyword used to specify the table (s) to be used?
C. EXISTS C. SELECT
D. FROM * D. SET
(5). Which SQL keyword must be used to remove duplicate rows from the result relation?
C. DELETE C. DISTINCT *
D. UNIQUE D. NOT EXISTS
(6). The language associated with a database management system that is employed by end users and
programmers to manipulate data in the database is the:
C. data definition language C. data presentation language
D. Data manipulation language * D. data translation language
(7). Three DDL commands:
C. CREATE, ALTER, DELETE C. INSERT, UPDATE, DELETE
D. CREATE, UPDATE, DROP D. CREATE, ALTER, DROP *
(8). SQL keyword used to state the condition that specifies which rows are to be selected?
C. EXISTS C. SET
D. FROM D. SELECT *
II. Specify the following queries in SQL on the COMPANY relational database schema shown in Figure
3.5. Show the result of each query if it is applied to the COMPANY database in Figure 3.6. (12 Marks)

(1) For every project located in ‘Stafford’, list the project number, the controlling department
number, and the department manager’s last name, address, and birth date.
Solution
SELECT Pnumber, Dnum, Lname, Address, Bdate
FROM PROJECT, DEPARTMENT, EMPLOYEE
WHERE Dnum=Dnumber AND Mgr_ssn=Ssn AND Plocation=‘Stafford’;

(2) Retrieve all employees whose address is in Houston, Texas.


Solution
SELECT Fname, Lname
FROM EMPLOYEE
WHERE Address LIKE ‘%Houston,TX%’;

(3) Retrieve a list of employees and the projects they are working on, ordered by department and,
within each department, ordered alphabetically by last name, then first name.
Solution
SELECT D.Dname, E.Lname, E.Fname, P.Pname
FROM DEPARTMENT D, EMPLOYEE E, WORKS_ON W, PROJECT P
WHERE D.Dnumber= E.Dno AND E.Ssn= W.Essn AND W.Pno= P.Pnumber
ORDER BY D.Dname, E.Lname, E.Fname;
------------- End of Solutions ---------------

You might also like