Académique Documents
Professionnel Documents
Culture Documents
com)
Contents
Part 1, i .................................................................................................................................................... 2
Scenario .................................................................................................................................................. 2
Create a E-R diagram following these steps ........................................................................................... 3
Part 1. ii ................................................................................................................................................... 5
Entity Types ............................................................................................................................................ 5
Main relationship to obtain a license ...................................................................................................... 5
Attributes ................................................................................................................................................ 5
Constraints: ............................................................................................................................................. 6
Degree of a Relationship (cardinality) .................................................................................................... 6
Keys ........................................................................................................................................................ 6
Entity integrity ........................................................................................................................................ 6
Referential integrity ................................................................................................................................ 7
It is referred to as foreign key in an entity suffixed “FK” ...................................................................... 7
Part 1, iii .................................................................................................................................................. 8
Normalisation.......................................................................................................................................... 8
First normal form (1NF) .......................................................................................................................... 9
Second normal form (2NF)...................................................................................................................... 9
Third normal form (3NF) ......................................................................................................................... 9
Part 2A................................................................................................................................................... 10
PART 2A. i .............................................................................................................................................. 10
Entity Relational Diagram (ERD) ......................................................................................................... 10
Structured Query Language (SQL) ....................................................................................................... 11
PART-2A .ii ............................................................................................................................................. 14
PART-2A (iii) .......................................................................................................................................... 15
PART-2A .iv ............................................................................................................................................ 15
Part 2B................................................................................................................................................... 15
PART-2B................................................................................................................................................. 16
PART-2B (i) ............................................................................................................................................ 21
PART 2B. i .............................................................................................................................................. 21
PART 2B. iii ............................................................................................................................................ 22
PART 2B.iv ............................................................................................................................................. 22
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Part 1, i
Scenario
Each office has a Manager [who tends to also be a Senior Instructor], several Senior
Instructors, Instructors, and administrative staff. The Manager is responsible for
the day-to-day running of the office. Clients must first register at an office and this
requires that they complete an application form, which records their personal
details. Before the first lesson, a client is requested to attend an interview with an
Instructor to assess the needs of the client and to ensure that the client holds a
valid provisional driving license. A client is free to ask for a particular Instructor or
to request that an Instructor to be changed at any stage throughout the process of
learning to drive. After the interview, the first lesson is booked. A client may
request individual lessons or book a block of lessons for a reduced fee. An
individual lesson is for one hour, which begins and ends at the office. A lesson is
with a particular Instructor in a particular car at a given time. Lessons can start
as early as 8am and as late as 6:30pm. After each lesson, the Instructor records the
progress made by the client and notes the mileage used during the lesson. The
School has a pool of cars, which are adapted for the purposes of teaching. Each
Instructor is allocated to a particular car. As well as teaching, the Instructors are
free to use the cars for personal use. The cars are inspected at regular intervals for
faults. Once ready, a client applies for a driving test date. To obtain a full driving
license the client must pass both the practical and theoretical parts of the test. It is
the responsibility of the Instructor to ensure that the client is best prepared for all
parts of the test. The Instructor is not responsible for testing the client and is not in
the car during the test but should be available to drop off and pick up the client
before and after the test at the DVLA Testing Centre. If a client fails to pass, the
Instructor must record the reasons for the failure.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
3. Figure out attributes of the entities and (if any) of the relationships.
Employee
School emp_id
school_id emp_fname
emp_lname
school_address emp_dob
school_loc emp_adress
emp_sex
emp_salary
emp_grade
school_id (FK)
Car
Addmin_Staff Teaching_Staff car_number Maintenance
Driving_test
Branch_DVLA test_code
Branch_id test_description
Branch_name test_place
Branch_contact test_time
Branch_address test_date
Branch_Loc test_centre
test_code (FK) test_duration
driver_id (FK) test_result
driver_id (FK)
License
license_id
license_type
license_issue_date
license_expiry_date
Branch_id (FK)
test_code (FK)
Driver's_License Learner's_License
license_id (FK) license_id (FK)
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Part 1. ii
Entity Types
An entity type is any type of object that we wish to store data about. Which entity types you
decide to include on your diagram depends on your application. In an accounting application
for a business you would store data about customers, suppliers, products, invoices and
payments and if the business manufactured the products, you would need to store data about
materials and production steps. Each of these would be classified as an entity type because
you would want to store data about each one. In an entity-relationship diagram an entity type
is shown as a box. Some entities in fig1.1 are as follows:
l. DriverTake ExamBranch
m. Branchissues License
Attributes
The data that we want to keep about each entity within an entity type is
contained in attributes. An attribute is some quality about the entities that we are
interested in and want to hold on the database. In fact we store the value of the
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
attributes on the database. Each entity within the entity type will have the same
set of attributes, but in general different attribute values. They are declared in fig 1.1
Constraints:
n. Each [driver] should <own>at least one [license].
r. 1: M (Driver, Exam).
Keys
It declare the Entity integrity and Referential integrity rule
Entity integrity
It is a Primary Key which is uniquely identify in an entity eg: Driver ID, Branch ID, License ID,
In the above model it is suffixed as “PK”. Entity Integrity certifies that there are no identical
records in a relation and that the field that finds each record within the table is not null.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Referential integrity
existence. When an FK directs to a record that doesn't occur, referential integrity is destroyed.
ON DELETE CASCADE
ON UPDATE CASCADE;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE CASCADE
ON UPDATE CASCADE;
show tables;
show databases;
Part 1, iii
Normalisation
Normalization is the process by which a given set of relations are transformed to a new set of
relations with a more solid structure.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Order
Car
orderNumber
carSerialNumber
orderDate
customerName carColourNames
orderCreationMethodName carMakeModelYearNote
verifyingEmployeeName
Orders
orderNumber Customer
Car
orderDate customerNumber
carSerialNumber
customerName customerName
orderCreationMethodName carColourNames
verifyingEmployeeName carMakeModelYearNote
Car
carSerialNumber
carColourNames
Order_car
carMakeModelYearNote
orderNumber (FK) customerNumber (FK)
orderDate
orderCreationMethodName
verifyingEmployeeName
carSerialNumber (FK)
Orders
Customer_oders
orderNumber
customerNumber
orderDate
customerName customerName
orderCreationMethodName orderNumber (FK)
verifyingEmployeeName
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Part 2A
PART 2A. i
Entity Relational Diagram (ERD) Part 1 into relational database tables
Introduction
In this part a Structured Query Language (SQL) data definition language, write a query to
transform any six (6) entities in ERD in part 1 into relational database tables.
School
Employee
school_id
emp_id
school_address
school_loc emp_fname
emp_id (FK) emp_lname
department_id (FK) emp_dob
emp_adress
emp_sex
emp_salary
Interview emp_grade
interview_id (FK)
Department interview_id
department_id interview_date
interview_time
department_name
driver_id (FK)
department_contact
emp_id
emp_id (FK)
Addministrative
Teaching
emp_id (FK)
emp_id (FK)
Driver_client
driver_id
driver_fname
driver_lname
driver_dob
driver_email
driver_address
driver_contact
emp_id (FK)
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
use QTM_2;
);
);
emp_dob datetime ,
);
);
);
ON DELETE CASCADE
ON UPDATE CASCADE;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ON DELETE CASCADE
ON UPDATE CASCADE;
PART-2A .ii
Creating a view that lists students with their corresponding department names.
PART-2A (iii)
Creating a course table and add a timestamp to ensure easy record keeping of changes to
courses in the department
ALTER TABLE driver_client
PART-2A .iv
Add a constraint to employee’s salary to ensure it is always positive
Part 2B
Implement a database application for QTM using SQL RDBMS
In the relational database management system (RDBMS), the data is represented as a set of
relations.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
Department
Department_Location
dept_id
loc_id
dept_fname
Office dept_id (FK)
dept_lname
dept_loc
client_id (FK) office_id
office_name Maintenance_inspection
staff_id (FK) main_id (FK)
Client inspec_date
inspec_remarks
client_id
client_fname Driving_test
client_lname
client_age test_code Test_Results
client_loc
test_type test_code (FK)
test_date
test_result Staff_Client
test_time
Staff test_remarks
test_loc staff_id (FK)
staff_id client_id (FK)
client_id
staff_fname
staff_lname
salary
Vehicle__Registration
maintenance
car_regisnumber (FK)
main_id
year
main_type Vehicle
fault_recorddate car_regisnumber
staff_id (FK)
Staff_grade
model
make staff_id (FK)
dept_id (FK)
staff_grade
PART-2B
RDBMS MYSQL script for fig2.1
*Declaring schema*
use RDBMS_2;
);
);
);
);
);
);
);
);
);
);
);
);
/*Adding constraints*/
PART-2B (i)
Create a Cartesian product by using two tables.
PART 2B. i
How many staff is hired currently and what is their average salary. What is the smallest
and biggest monthly salary? How much must be paid each month for the salaries?
PART 2B.iv
List all clients that took driving test in Accra centre but came from Tema
/* all client who took test in Accra but came from Tema*/
PART 2B.v
Generate a table that lists all vehicles that has been assigned to a lesson and all clients
who have enrolled for that lesson.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
AND ALL CLIENTS HAVE ENROLLED ON THAT LESSON. IMPLIES ALL VEHICLES = ALL CLIENTS
PART 2B. vi
SHOW TABLES;
PART 2B .vii
Select the first 10 Toyota Avensis vehicles for inspection.
PART2B.VIII
Select all clients who have their first name as the first name of the staff who interviewed
them.
Is the external user needs dynamic results from of one or more relational operations
operating on the base relations to produce personal records, this is virtual does not exist
in the main database but obtain upon query by end user. This has to be managed well to
avoid intrusion or deletion of important data from the database. Hence there should be
In recent times there has being great Increase in the level of attacks from both inside and
outside organisations. More sophisticated password breakers and database rootkits available.
Hence Data is a valuable resource that must be strictly controlled and managed, as with any
corporate resource. Most part of the company data may have strategic importance and
therefore needs to be kept secure and private. Measures have to be put in place that must
protect the database against intentional or internal threats. Security considerations do not only
relate to the data held in a database but breaches of security may affect other parts of the
This involves measures to avoid theft and fraud, Loss of confidentiality (secrecy) and Loss
of privacy.
Mamudu.eee@k.poly, 2014_07 (drsennet@gmail.com)
For a better management practice one has to look at the following to cater for effective
security:
Journaling: Process of keeping and maintaining a log file (or journal) of all changes made to
Integrity: Prevents data from becoming invalid, and hence giving misleading or incorrect
results.
Encryption: The encoding of the data by a special algorithm that renders the data unreadable
It is a process of occasionally taking a duplicate of the database and log file to offline storage
media to serve as a means to keep data from being lost in terms of any eventualities.
Approaches used in backups include; eencryption data in the backup, password protect access
to the backup, test and validate the backups to ensure integrity, store in safe place away from
Reference
"database, n". OED Online. Oxford University Press. June 2013. [Assessed on June 12, 2014]
Childs, D. L., (1968) Description of a set-theoretic data structure, Technical Report 3 of the
Kahn, D.L. etal (1977)MICRO Information Management System (Version 5.0) Reference
Manual., Institute of Labor and Industrial Relations (ILIR), University of Michigan and