Database Questions
Database Questions
1. A garden design company keeps records of its customers. Each customer has had a design produced for them
which will be one of a library of design types stored by the company. Each design type uses plants. Each
customer is sent an account based on the number of plants in the design.
(a) Draw an E-R (entity-relationship) diagram in third normal form, based on this information. [10]
(b) Each delivery of plants to the garden design company is identified by a batch number. Explain how
customers who received eucalyptus trees from batch 12 can be contacted. [4]
2. A sports club runs a number of sports teams.
Each team is made up of a number of members of the club and each member may play for more than one team.
Each team has a number of coaches, but the coach‘s job is so time consuming that each coach can only coach
one team.
Represent the above information on an entity relation (ER) diagram, in 3rd normal form, stating the primary
key for each entity. [13]
3. (a) In relation to databases, describe what is meant by each of the following terms.
(i) Primary key. [1]
(ii) Secondary key. [1]
(iii) Foreign key. [1]
(b) Using, as an example, the database of student records in a school,
(i) Explain why different users should be given different access rights; [4]
(ii) Describe how these access rights can be implemented. [4]
4. A landscape garden company services a number of gardens. Each GARDEN is owned by an OWNER. Each
owner may have more than one garden. Each garden has a number of PLANTS in it and each plant may be in a
number of gardens.
Draw an entity relationship (E-R) diagram to represent this data model in third normal form and label the
relationships. [10]
5. A health centre employs doctors, nurses and receptionists.
The data that is stored about the patients includes their medical history and personal information about them.
Explain the need for maintaining privacy of the data and describe methods by which the database management
system (DBMS) can help to achieve this. [6]
7. (a) Describe the function and purpose of the following parts of a database management system
(DBMS):
(i) data dictionary, [2]
(ii) data description language, [2]
(iii) data manipulation language. [2]
(b) Three advantages of using a relational database rather than flat files are:
(i) reduced data duplication,
(ii) improved data security,
(iii) improved data integrity.
Explain what is meant by each of these and why they are features of a relational database. [6]
8. A university consists of a number of departments. Each department offers several courses. A number of
modules make up each course. Students enrol in a particular course and take modules towards the
completion of that course. Each module is taught by a lecturer from the appropriate department, and each
lecturer tutors a group of students. Draw an ER diagram to represent this showing all entities and
relationships [20 marks]
9. (a) Describe what is meant by:
(i) A backup of data [2]
(ii) An archive of data [2]
(b) The data collected by a survey team and the results of processing are both backed up and archived.
(i) Explain why it would be important to take a backup of the results of a survey [2]
(ii) Explain why it would be important to archive the results of a survey [2]
1
Database Exercise
1. Every student in a school belongs to a form. Every form has a form tutor and all the form tutors are
teachers. Because some teachers are part-time, some forms have more than one form tutor although no
teacher is a form tutor for more than one form. Students are identified by StudentID and each form has a
unique name.
a. Draw an entity–relationship diagram to show the relationships between the entities STUDENT, FORM
and TUTOR. [6]
b. Describe the relationship between FORM and STUDENT. [1]
c. Describe how this relationship is formed. [2]
2. Consider the scenario from Question 1 with the addition of a DEPARTMENT entity. Each tutor can work
in one or more departments and each department has many tutors. That part of the diagram is shown in
Figure
7. A shop sells drinks. The shop has name, address and licenceno fields. Drinks have name and
manufacturer fields. Customers like drinks. Customers have name and address.
Draw an ER Diagram to illustrate the above relationship. [11]
QUESTION: Convert the following table to Third Normal Form (3NF) [ 15]
2
Question 1
3
a) Using your own data deduce and explain the resultant of the following SQL statement
I. SELECT name FROM s WHERE city='Rome' [4 marks]
II. SELECT sp.*, city
FROM sp, s
WHERE sp.sno=s.sno [4 marks]
b) Let
I. Retrieves the numbers which identify employees working for companies located in London.
II. Computes the average salary of the employees working for a company whose company number is "C111"
[10 marks]
Question 2
4
TEST PAPER 2 (PRACTICAL)
1. The following is an un-normalised table named Delivery Note.
(a) (i) Draw the 1NF of the above table. Underline Primary Key field(s). [5] ~ INF
PRODUCT (prod numb, prod description)
DELIVERY (cust numb, cust name, city, country, prod numb)
(ii) Come up with the 2NF of the table you created, indicating Primary Key field(s). [14] ~ 2NF
PRODUCT (prod numb, prod description)
prod numb prod description
19 Bag
20 Shoes
21 Socks
22 Umbrella
DELIVERY (cust numb, prod numb)
cust numb prod numb
209 19
209 20
209 21
209 22
198 20
198 21
CUSTOMRER(cust numb, cust name, city, country)
cust numb cust name city country
209 Peter Mutare Zim
198 Bruce Gwanda Zim
(b) A shop sells drinks. The shop has name, address and licenceno fields. Drinks have name and manufacturer fields.
Customers like drinks. Customers have name and address.
Draw an ER Diagram to illustrate the above relationship. [11]
2. (a) At ABC High School, a teacher teaches many subjects. A student enrols in many subjects and attends four
lessons per week for each subject. Each subject is taught by several teachers.
Draw an entity-relation diagram to show relationships between the entities. On the diagram, show the primary key
and at least one attribute for each entity. [15]
(b) (i) Draw a well-labelled diagram showing the different views of the Database Management System Structure. [8]
QUESTION 3
Create the following tables for part of a relational database maintained by HIT and set primary and foreign keys
where necessary. [7]
Lecturer (Lecturer-initials, Name, Title, Department, Email-address)
Course (Course-code, Course -title)
Teaches (Lecturer-initials, Course-code)
Class (Course-code, day, time, place, term)
Registration (Student-name, Course-code) (assume student names are unique)
Using your own data, write expressions in SQL to retrieve each of the following
(a) Email addresses of lecturers in the department known as Computer Science sorted in alphabet order [4]
(b) A list of the names of students taking the course entitled ‘Advanced databases’ [4]
(c) A list showing the names of lecturers and the titles of the courses they teach [5]
3(a) SELECT Name,Email_Address FROM `lecturer` WHERE Department = 'Computer Science' ORDER by Name ASC
(b) SELECT Student_Name , Course_Title FROM `course` JOIN registration ON course.Course_Code =
registration.Course_Code WHERE registration.Course_Code=0004
(c) SELECT Name , Course_Title FROM `teaches` JOIN lecturer ON teaches.Lecturer_Initials = lecturer.Lecturer_initials
JOIN course ON teaches.Course_code = course.Course_Code WHERE 1
5
Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs
(also called applications) written in a variety of .NET programming languages. This IDE is a powerful and sophisticated tool for
creating business- critical and mission-critical applications.
6
7
6. State the relationship between the following cinema table and determine its cardinality [8]
8
ER DIAGRAM
9
1NF
10