You are on page 1of 5

1.

An attribute that is part of a key is known as a(n) ___ attribute

PRIME

2. A table that displays data redundancies yields ___

ALL OF THE ABOVE (update, deletion and insertion)

3. A(n) ___ exists when there are functional dependencies such that WZ is functionally
dependent on XY, W is functionally dependent on X, and XY is the primary key

PARTIAL DEPENDENCY

4. A(n) exists when there are functional dependencies such the Y is functionally dependent
on X, Z is functionally dependent on Y and X is the primary key

TRANSITIVE DEPENDENCY

5. A ___ derives its name from the fact that a collection of multiple entries of the same
type can exist for any single key attribute occurrence

REPEATING GROUPS

6. A relational table must not contain a(n) ___

Maybe repeating groups

7. Dependencies based on only a part of a composite primary key are known as ___
dependencies

PARTIAL

8. A table that is in 2NF and contains no transitive dependencies is said to be in ___

3NF

9. The SQL command that allows a user to permanently save data changes is ___

COMMIT

10. The SQL command that allows a user to list the contents of a table is ___

SELECT
11. The ___ command is used to restore the database to its previous condition

ROLLBACK;

12. The ___ command would be used to delete the table row where the P_CODE is ‘BRT-
345’

DELETE FROM PRODUCT WHERE P_CODE = ‘BRT-345’;

13. Which of the following queries will output the table contents when the value of V_CODE
is equal to 21344?

SELECT P_DESCRIPT, P_INDATE, P_PRICE, V_CODE FROM PRODUCT WHERE V_CODE =


21344

14. Which of the following queries will use the given columns and column aliases from the
PRODUCT table to determine the total value of inventory held on hand?

SELECT P_DESCRIPT, P_QOH, P_PRICE, P_QOH*P_PRICE FROM PRODUCT;

15. Which of the following queries uses the correct SQL syntax to list the table contents for
either V_CODE = 21344 or V_CODE = 24288?

SELECT P_DESCRIPT, P_INDATE, P_PRICE, V_CODE FROM PRODUCT WHERE V_CODE =


21344 OR V_CODE = 24288;

16. The special operator used to check whether an attribute value is within a range of values
is __

BETWEEN

17. Which of the following queries will output the table contents when the value V_CODE is
NOT equal to 21344?

SELECT P_DESCRIPT, P_INDATE, P_PRICE, V_CODE FROM PRODUCT WHERE


V_CODE < > 21344;

18. The SQL query to output the contents of the EMPLOYEE table sorted by last name, first
name, and initial is ___
SELECT EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_AREACODE, EMP_PHONE FROM
EMPLOYEE ORDER BY EMP_LNAME, EMP_FNAME, EMP_INITIAL;

19. A table can be deleted from the database by using the ___ command

DROP TABLE

20. The query to join the P_DESCRIPT and P_PRICE fields from the PRODUCT table and the
V_NAME, V_AREACODE, V_PHONE and V_CONTACT fields from the VENDOR table,
where the values of V_CODE match and the output is ordered by the price is ___

SELECT PRODUCT.P_DESCRIPT, PRODUCT.P_PRICE, VENDOR.V_NAME,


VENDOR.V_CONTACT, VENDOR.V_AREACODE, VENDOR.V_PHONE FROM
PRODUCT, VENDOR WHERE PRODUCT.V_CODE = VENDOR.V_CODE; ORDER BY
PRODUCT.P_PRICE;

21. A database language enables the user to perform complex queries designed to
transform the raw data into useful information

TRUE

22. Entity integrity is enforced automatically when the primary key is specified in the
CREATE TABLE command sequence

TRUE

23. SQL Queries


Based on the table below
Table name: EMP_1
i. Write the SQL code to enter the data for first row for the table shown above

INSERT INTO EMP_1 VALUES (‘101’, ‘News’, ‘John’, ‘G’, ’08-Nov-00’, ‘502’);

ii. Assuming the data shown in the EMP_1 table been entered write the SQL code
that will list all attributes for a job code of 502

SELECT JOB_CODE
FROM EMP_1
WHERE JOB_CODE = ‘502’;
iii. What would be the output of executing the on the SQL code you write in
question ii. Note that query is valid

101, NEWS, JOHN, G, 08-NOV-00, 502

24. Based on the table below answer the following question


Table name: invoice
CUS_CODE INV_NUMBER . . .
i. Write the SQL code to display cust_code, inv_number of the customer whose
purchase order was greater than $100

SELECT cust_code, inv_number


From invoice
WHERE subtotal > 100

ii. Write the SQL code to display the average purchases of the customers

SELECT AVG (UNITPRICE)


FROM invoice

iii. What should be the output of executing the following query on table invoice?
Note that query is valid
SELECT INV_NUMBER, UNITS_BOUGHT, UNIT_PRICE, SUBTOTAL
FROM INVOICE
WHERE SUBTOTAL BETWEEN 4.99 and 14.97
AND UNITS_BOUGHT > = 2;

25. Considering the ER model and tables given below, answer to the following questions
Departments is one and employees is many
Department tubules record
Employee tubules record
Indicate for each following expression whether it is valid SQL statement or not. A valid
query complies with SQL syntax and doesn’t result its error when executed. Use the
below table for your answer
a. INSERT INTO departments (department_id, department_name) VALUES (NULL, ‘IT
Test’);
b. INSERT INTO employees (last_name, department_id, employee_id) VALUES (‘Taylor’,
60, 110);
c. INSERT INTO employees (employee_id, last_name, department_id) VALUES (108,
‘Smith’, NULL);
d. UPDATE employees SET employees_id = 100;
e. UPDATE employees SET last_name = ‘John’ where employee_id = 107;
ANSWER

A is invalid
B is valid
C is invalid
D is invalid
E is valid

26. Decompose the following dependency diagram to tables in 3NF (third normal form)
Note: this dependency diagram is about medicine prescription given by a doctor to a
patient
Medname is primary key, patientID is primary key, date primary key, refillsallowed,
patientname, dosage, shelflife

1NF

PK = medname, patientID, Date


PD1 = Medname, ShelfLife
PD2= patientID, patientname
(No Transitive dependency)

2NF

T1 = medname, shelflife
T2= patientID, patientname
T3 = medname, patientid, date, refillallowed, dosage

3NF

T1 = medname, shelflife
T2= patientid, patientname
T3 = medname, patientid, date, refillallowed, dosage
(there is no transitive dependency)

You might also like