Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 29

START

ER
ASSIG
NMENT

Submitted By:
Animesh Nepal

1
Entity Relationship Model
The ER Diagram of the given data and tables with normalization up to 3 rd normal
form is below.

2
Normalization of given data
 Table 1 (Session and Fees)

The given table is in 2nd normalized form already. Here, the price is dependent upon
the floor and the floor is dependent upon the session type. So, to change that into transitive
dependency the table is split up into two tables as shown above.

 Table 2 (Session Staff Role)

To make the table normalized, new column Staff Id and Role Id was inserted
and the table was split into two with Role Id as a foreign key in ‘Staff Info’ table as
shown above.

 Table 3 (Booking Lists)

For this table, two new columns were added, Booking Id and Customer Id
respectively to break down the table to 2NF form. Then the table is separated into two, one
with booking details and another linked to the customer information.

3
 Table 4 (Arcade Machine Information)

The given table has all of its columns dependent on the primary key i.e. Machine
Number and is already in 3rd Normal Form.

 Table 5 (Consoles and Games)

For this table, I’ve added two new columns Game Id and Console Id to identify games
and consoles respectively. And later the tables are separated into consoles and games to
remove partial dependency

 Sessions and Consoles

With the given table in 1NF, the partial dependency between console quantity and session
have been removed by introducing a new columns i.e. Console Id and the table is
separated into two, one with session information and other one with console information.

4
 Table 7 (Customers)

A new column, Customer Id is introduced in the table to get it to 1NF. And since, fees
depends upon the member type, new column Member ID is added and the table is split up
into two as shown above. Also, the address column of the customers is split into two
columns Street name and City to reduce data redundancy.

5
Data Dictionary

 Table: arcade_machine
Columns

Name Data type Description / Attributes


Machine Number int(10, 0)
Game varchar(50) Nullable
Year int(10, 0) Nullable
Nullable
Floor int(10, 0) References:
floor_price
Links to

Table Join Title / Name / Description


arcade_machine.Floor = fk_floors
floor_price
floor_price.Floor

Unique keys
Columns Name / Description
Machine Number PRIMARY

 Table: bookings
Columns

Name Data type Description / Attributes


Booking id int(10, 0)
Session Number int(10, 0) Nullable
Nullable
Customer Id int(10, 0)
References: customer_info
Date date Nullable
Pre-paid varchar(10) Nullable
Fee varchar(50) Nullable

6
Links to

Table Join Title / Name / Description


bookings.Customer Id = fk_customerid
customer_info customer_info.Customer
Id

Unique keys
Columns Name / Description
Booking id PRIMARY
 Table: console
Columns

Name Data type Description / Attributes


Nullable
Console Id int(10, 0) References:
consoles
Console varchar(10) Nullable
Qty int(10, 0) Nullable
Links to

Table Join Title / Name / Description


console.Console Id = fk_consoleid
consoles
consoles.Console Id 1

 Table: consoles
Columns

Name Data type Description / Attributes


Console Id int(10, 0)
Console varchar(50) Nullable
Console Qty int(10, 0) Nullable

7
Linked from

Table Join Title / Name / Description


consoles.Console Id = fk_consoleid1
console
console.Console Id
consoles.Console Id = fk_consoleid
games
games.Console Id
consoles.Console Id = fk_consoleid2
sessions
sessions.Console Id
Unique keys
Columns Name / Description

Console Id PRIMARY

 Table: customer_info
Columns

Name Data type Description / Attributes


Customer Id int(10, 0)
Firstname varchar(50) Nullable
Lastname varchar(50) Nullable
Member varchar(1) Nullable
Linked from

Table Join Title / Name / Description


customer_info.Customer fk_customeri
bookings Id = bookings.Customer d
Id
Unique keys

Columns Name / Description


Customer Id PRIMARY

8
 Table: customers

Columns

Name Data type Description / Attributes


Person Id int(10, 0)
Firstname varchar(50) Nullable
Lastname varchar(50) Nullable
Street varchar(50) Nullable
City varchar(50) Nullable
Date of Birth date Nullable
Nullable
Member Id int(10, 0)
References: members_info
Joined Date date Nullable
Links to

Table Join Title / Name / Description


customers.Member Id = fk_memberid
members_info members_info.Member
Id

Unique keys
Columns Name / Description
Person Id PRIMARY
 Table: floor_price
Columns

Name Data type Description / Attributes


Floor int(10, 0)
Price varchar(50) Nullable
Linked from

Table Join Title / Name / Description


floor_price.Floor = fk_floors
arcade_machine
arcade_machine.Floor
sessions_info floor_price.Floor = fk_floor
sessions_info.Floor
Unique keys

Columns Name / Description


Floor PRIMARY

9
 Table: games
Columns

Name Data type Description / Attributes


Game Id int(10, 0)
Name varchar(50) Nullable
PEGI varchar(10) Nullable
Nullable
Console Id int(10, 0) References:
consoles
Links to

Table Join Title / Name / Description


console games.Console Id = fk_consoleid
s consoles.Console Id
Unique
keys
Columns Name / Description
Game Id PRIMARY

 Table: members_info
Columns

Name Data type Description / Attributes


Member Id int(10, 0)
Member varchar(5) Nullable
Member Type varchar(15) Nullable
Member Fee varchar(10) Nullable

10
Linked from

Table Join Title / Name / Description


members_info.Member fk_memberid
customer
Id = customers.Member
s
Id

Unique keys
Columns Name / Description
Member PRIMARY
Id

 Table: sessions
Columns

Name Data type Description / Attributes


Session Number int(10, 0)
Date date Nullable
Nullable
Console Id int(10, 0) References:
consoles
Links to

Table Join Title / Name / Description


sessions.Console Id = fk_consoleid2
consoles
consoles.Console Id

Unique keys
Columns Name / Description
Session Number PRIMARY

11
 Table: sessions_info

Columns

Name Data type Description / Attributes


Session Number int(10, 0)
Session Day varchar(50) Nullable
Session Start Time varchar(10) Nullable
Session End Time varchar(10) Nullable
Session Type varchar(50) Nullable
Nullable
Floor int(10, 0) References:
floor_price
Links to

Table Join Title / Name / Description


floor_price sessions_info.Floor = fk_floor
floor_price.Floor

Unique keys
Columns Name / Description
Session Number PRIMARY

 Table: staff_info
Columns

Name Data type Description / Attributes


Staff Id int(10, 0)
Staff Name varchar(100) Nullable
Session int(10, 0) Nullable
Nullable
Role Id int(10, 0) References:
staff_role

Links to

Table Join Title / Name / Description


staff_role staff_info.Role Id = fk_roleid

12
staff_role.Role Id
Unique keys
Columns Name / Description

Staff Id PRIMARY

 Table: staff_role
Columns

Name Data type Description / Attributes


Role int(10, 0)
Id
Role varchar(50) Nullable
Linked from

Table Join Title / Name / Description


staff_info staff_role.Role Id = fk_roleid
staff_info.Role Id

Unique keys
Columns Name / Description
Role Id PRIMARY

13
Finished tables and SQL Script
 Floor and Price Table

 Session Information Table

14
 Staff Role Table

 Staff Information Table

15
 Customer Information Table

 Bookings Table

16
 Arcade Machine Information Table

 Consoles Table

17
 Games Information Table

 Game Console Table

 Sessions Table

18
 Members Information Table

 Customer Table

19
Tables with data and SQL Scripts
 Floor and Price

 Session Information Table

20
 Staff Role Table

 Staff Information Table

21
 Customer Information Table

 Bookings Information Table

22
 Arcade Machine Information Table

 Consoles Information Table

23
 Games Information Table

 Console Games Table

24
 Sessions Console Table

 Members Information Table

25
 Customers Table

 Select all customers booked on session 1 who have not yet paid

 Select all machines on floor 2 by year in descending order

26
 Count all the console games for the PS2

 Select all customers who have a premium membership in descending


order of surname

 Select all the staff working on session 1 on the counter

27
 Update the floor for Mario from floor 1 to floor 2

 Update the start time for session 1 to 11.30 am

 Update the membership type from standard to premium for the


customer ‘Kylie Mason’

28
 Delete the machine Phoenix

 Delete Gemma Hoyle from the staff rota for session 1

29

You might also like