Professional Documents
Culture Documents
“Start riding” is a chain of bike repair shops in Sydney. Because of the prevailing COVID 19
pandemic and increasing competition, the owners want to track the repair jobs for bikes they
repair, the items used for each repair job, the labor costs for each repair job, the mechanic
performing each repair job, and the total cost of each repair job.
The process is as follows:
When customers bring their bikes in to be repaired, they need to pay a deposit on the repair
job and are given a date to return and pick up their bikes after the mechanic evaluates the
repair job. Mechanic then perform the repairs on the customers’ bikes, details the labor costs
and the items used for each repair job.
When customers return on the date advised, they must pay the total cost of the repair job
less the deposit, collect a receipt for their payment, and pick up the repaired bikes using this
payment receipt.
Group Tasks
Task 1 ER Diagram 5 marks
List all the dependencies in a dependency diagram including partial and transitive.
Show the determinants and select primary key, foreign key.
Starting with unnormalized data, convert all the tables to 1 NF. Clearly outline the
rules for a table to be in 1 NF and provide justification.
Identify partial dependency if any and resolve it.
Identify transitive dependency if any and resolve it.
Make sure the tables are in BCNF. Explain the rule with tables as example.
Identify multivalued dependency if any and resolve it.
At each stage list the rules and provide explanation of why the tables are in 2, 3 or 4
NF.
Task 3 10 marks
1. Write table creation scripts for all the entities identified in ERD above and insert a few
records in each table. 5 marks
2. Write the below queries: 5 marks
a. Listing of jobs on hand, mechanics working on them and items required for the job
arranged in descending order of completion date
b. List of customers who have paid more than $ 200 on the total job and a deposit of over $
50
c. A summary of all jobs that require more than 2 items to fix.
d. Names of mechanics who are working on more than 2 jobs at the same time.
e. Create a view which shows a list of repeat customers (those who have availed services
more than once). This view should display the name of mechanic, items used and total cost
for each of the jobs for these customers.
Answer: -
TASK-1
Before Normalization:
Customer_id integer
Customer_name varchar (20)
Customer_add varchar (200)
Invoice_id_FK integer
Deposit_Amt currency
Customer_cellno integer
Mechanic_id integer
Job_id_FK
Mechanic_name
Labour cost currency
Job_id integer
Item_id_FK integer
Item_id integer
Item_name varchar (20)
Item_type varchar (20)
Item_cost currency
Invoice_id integer
Customer_id_FK
Total_amount currency currency
Adv_paid currency
Pickup_date date
Booked_Date date
TASK-2
Task-3
Create Table script:
CREATE TABLE CUSTOMER(
Customer_id INT PRIMARY KEY NOT NULL,
Customer_name VARCHAR(20) NULL,
Customer_add VARCHAR(200) NULL,
Invoice_id_FK INT FOREIGN KEY REFERENCES BOOKING(Invoice_id)
Customer_cellno INT NOT NULL,
Deposit_Amt money NULL,
);
GO
CREATE JOB(
Job_id INT PRIMARY KEY NOT NULL,
Mechanic_id_FK INT FOREIGN KEY REFERENCES MECHANIC(Mechanic_id)
Labour cost money NULL,
Item_id_FK INT FOREIGN KEY REFERENCES ITEM(Item_id)
);
GO
CREATE ITEM(
Item_id INT PRIMARY KEY NOT NULL,
Item_name VARCHAR(20) NULL,
Item_type VARCHAR(20) NULL,
Labour cost money NULL,
);
GO
=========================
Insert data
b)SELECT e1.customer_name
FROM customer e1,e2.Booking
WHERE Deposit_Amt >= 200 and Totak_amount>200