Sie sind auf Seite 1von 9

Section A Data Dictionary

Table_Name Attribute_Name Type Format Range Required PK/


FK
Officer Officer_ID Integer 10200 10000-99999 Y PK
First_Name VarCHAR(20) Xxxxxxxx Y
Surname VarCHAR(20) Xxxxxxxx Y
Position Text Xxxxx
Gender Text Xxxx
Shift Text Xxxx
Offender Licence_No. Long_Integer 111001122 Y PK
First_name VarCHAR(20) Xxxxxxxx Y
Surname VarCHAR(20) Xxxxxxxx Y
Postal_address Xx Xxx Xxx Y
Vehicle Text Xxxx
Vehicle_No. Integer 99999 FK
Y
Vehicle Chassis_number Integer 9999999 Y PK
Make Text Xxxxxxx Y
Model Text Xxxxxx Y
Type_ofVehicle Text Xxxx
Y_manufacture Integer mmm-yyyy
Mileage integer 99999 Y
Arrest Offence_No. Integer 9999 Y FK
Officer_No. VarCHAR(5) 99999 Y FK
Vehicle_No. Integer 9999 Y FK
Licence_No. Long integer 9-999-999-99 FK
Date Date dd-mmm-yyyy
Time Time hh:mm:ss
Area VarCHAR(20) Xxxxxx

Offence Offence_No. Integer 99999 PK


Offence_name VarCHAR(20) Xxxxxx Y
Fine float 00.00
ER Diagram

Manu.Year
Mileage

Model Offence_name

Fine Offence
Vehicle
Make

Chassis_No Offence
Vehicle_No

License_No Uses
Fine
FirstName s

Surname Offender
Offence_No

PO_Address
Is
Officer_ID

Vehicle
Vehicle_No Vehicle_No
Arrest
License_No

Date
Shift Area Time
Gender Fine
s

Position
Officer

Surname

FullName Officer_ID
TRANSACTION REQUIREMENTS

A. DATA ENTRY
B.
a) DETAILS OF AN OFFICER

INSERT INTO OFFICER (OFFICER_ID, FIRST_NAME, SURNAME, POSITION, GENDER, SHIFT)

VALUES (901126, Samu, Malambe, Inspector, Male, Night);

b) DETAILS OF OFFENCE

INSERT INTO OFFENCE (OFFENCE_NO, OFFENCE_NAME, FINE)

VALUES (006721, Over speeding, 200.00);

c) DETAILS OF OFFENDER

INSERT INTO OFFENDER (LICENSE_NO, FIRST_NAME, SURNAME, POSTAL_ADDRESS, VEHICLE,


VEHICLE_NO)

VALUES (200076590, Sethu, Fakudze, P.O Box 76_Mbabane, Bakkie, 15000);

C. DATA UPDATE

UPDATE ARREST

SET

OFFENSE_NO=15001,

OFFICER_NO=65100,

VEHICLE_NO=120010,

LICENSE_NO=1320201900,

DATE= 10/008/2020,

TIME=10:00,

AREA=’Mvutjini’

WHERE

License No= 2000126005;


UPDATE DETAILS OF A VEHICLE

SET

CHASSIS-NO = 23444,

MAKE= Toyota,

MODEL= Fortuner,

TYPE OF VEHICLE=bakkie,

YEAR= 2018,

MILEAGE= 12000KM;

WHERE

CHASSIS-NO=23444;

DELET FROM ARREST

WHERE LISENCE NO. =98670965432677;

B. FORMS

Officer Form
Officer ID: ADD

First Name:
Surname:
UPDATE
Position:
Gender: DELETE

Shift:
Offender Form
Licence No.
First Name:
Surname:
Postal Address:
Vehicle:
Vehicle No:

ADD SEARCH UPDATE DELETE

Offence Form

Offence No:
Offence Name:
Fine:

ADD SEARCH UPDATE DELETE


Section B SQL

 Query to create table customers

CREATE TABLE IF NOT EXIST CUSTOMERS

(Customer_ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,

Customer_Name VARCHAR (50) NOT NULL,

Address VARCHAR (50) NOT NULL);

CREATE TABLE IF NOT EXIST VEHICLES

(Vehicle_ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,

Name VARCHAR (50) NOT NULL);

CREATE TABLE IF NOT EXIST RENTALS

(Customer_ID INTEGER NOT NULL,

Vehicle ID INTEGER NOT NULL,

Rental_Start_Date DATE NOT NULL,

Rental_End_Date DATE NOT NULL,

FOREIGN KEY (Customer_ID) REFERENCES Customers (Customer_ID),

FOREIGN KEY (Vehicle_ID) REFERENCES Vehicles (Vehicle_ID));

b) SQL statement to change name of the vehicle ‘VW CAMPER’ to ‘VW LUXURY CAMPER’

UPDATE Vehicle

set Name = ‘VW LUXURY CAMPER’

WHERE Vehicle ID= 3;


c) SQL statement display the customer ID, Vehicle ID and Vehicle name

SELECT Customer_ID, Vehicle_ID, Vehicle.Name

FROM Rentals

JOIN Vehicles ON Vehicle.Vehicle_ID;

d) SQL statement to display customers whose name is Mandy Jackson and address contains Treetop

SELECT *FROM Customers

WHERE

Customer Name like ‘%Mandy Jackson%’

AND Address like ‘%Treetop%’

e) Query to update rental end date for vehicle VW Camper to 30/01/2016

UPDATE Rentals

SET Rental End Date=’30/01/2016’

WHERE Vehicle_ID (SELECT Vehicle_ID FROM Vehicles WHERE Name=’VW Camper’);

F) A query for all vehicle that were not rented

SELECT *FROM Vehicle

WHERE Vehicle_ID NOT IN (SELECT Vehicle FROM Rentals);


Section C

1NF (First Normal Form) Rules

 Each table cell should contain a single value.

 Each record needs to be unique.

2NF (Second Normal Form) Rules

 Rule 1- Be in 1NF

 Rule 2- Single Column Primary Key

Divide our 1NF table into two tables viz. Table 1 and Table2. Table 1 contains member information.
Table 2 contains information on movies rented.

We have introduced a new column called Membership id which is the primary key for table 1. Records
can be uniquely identified in Table 1 using membership id

3NF (Third Normal Form) Rules

 Rule 1- Be in 2NF

 Rule 2- Has no transitive functional dependencies


To move our 2NF table into 3NF, divide table.

Divide our tables and create a new table which stores Salutations. 

In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary key in Table 3

Das könnte Ihnen auch gefallen