Cit 3201 Database Systems
Cit 3201 Database Systems
a) Explain the three categories of anomalies that may be experienced when working with
tables that are not normalized (6 marks)
b) Explain the purpose of indexes in a database management system (2 marks)
c) Early Morning Chemist is a pharmaceutical outlet company that offers drug dispensing
services to the public. The company has a database that includes a record of all of the
drugs in its inventory i.e. thedrugs table, with the following details of drugs;
drugid, name,manufacturer,form, route.
Write SQL expressions to.
i. Create the products table, including a primary key. (3marks)
ii. Insert the following details into the products table.
name = Argumentin 500mg, manufacturer=GSK, form = suspension, route=oral
(3marks)
iii. Insert a column called substitute to store information on probable replacement
drug in case the subject drug is out of stock. (3marks)
iv. Write an expression that would extract only those drugs whose name start with the
letters “br” (3marks)
QUESTION THREE (20 MARKS)
a) Describe any two wildcard characters used in structured query language (4 marks)
b) Consider an online company selling a wide range of products to its customers.
The customer table should have customerID, name, address, phone fields; while
the products table should include ProductID, name, type, and price fields. Your
tables should have primary keys. For each field determine the “null” constraint
too.
i) Write SQL queries to create tables for customers and products of the company.
(4 Marks)
Further, assuming that customers can make orders for different products, whereby
each order can only includeitems referring to only one product. Eg. an order for
bags of cement, and a separate order for several tins of paint. The number of items
(qty) ordered and the order date (odate) should also be stored.
ii) Using an ER diagram, explain how the orders table can be added to the database.
(4 Marks)
iii) Write necessary SQL commands to add the orders table to the database.
(4 Marks)
c) Use SQL statements grant the following permission to a user names “john”
i) Insert records to the products table (2 marks)
ii) View records in the products table (2 marks)