You are on page 1of 100

DBMS - IT 214

Team ID : S5 - T3
Project title : Game Zone DBMS
Mentor Name: Shreyas Sir

Sr. No. Student ID Name


1 Neel Patel 201901068
2 Siddharth Rathod 201901159
3 Harshal Mavani 201901162
4 Yash Sakaria 201901165

Final Version
Nov 26, 2021
Index
1. Section1: Final version of SRS.
2. Section2: Noun Analysis.
3. Section3: ER-Diagrams all versions.
4. Section4: Conversion of Final ER-Diagram to Relational Model.
5. Section5: Normalization and Schema Refinement.
6. Section6: SQL: Final DDL Scripts, Insert statements, 40
SQL Queries with
Snapshots of output of each query.
7. Section7: Project Code with output screenshots.
Section 1: Final version of SRS

1. Introduction
a. Purpose
b. Intended audience and reading suggestion
c. Product scope
d. Description
2. Document the Requirements Collection/ Fact Finding Phase
a. Readings and Description
b. Interviews
c. Questionnaires
d. Observations
3. Fact Finding Chart
4. List requirements
5. User classes and characteristics
6. Operating Environment
a. Hardware, Software and Connectivity requirements
b. External Interface requirements
7. Product functions
8. Privileges
a. List functions and User Privileges
9. Assumptions
10.Business Constraints
1. Introduction

a. Purpose

The primary purpose of this document is to create a database for managing Data in a Game Zone and
creating a system that will make the work of the Game zone employees and customers much easier. The
purpose of this system will be to keep track of customers, their debits and account balance, games played,
playing hours, eligibility, waiting list...etc.

This database will provide fast and convenient access to the required data and allow customers to view their
profile and will allow employees to keep track of their customers, modify them as per their requirements.
This document serves as a guide for developers of this management system.

b. Intended Audience and Reading Suggestions

The document is intended for:

● Game Zone owner: They are the admin of the database. They have all the rights and can also
add/remove managers.

● Game Zone manager (User): These will be the main users. They can add/remove customers,
update any information of the users, etc. In short, they are the manager of the database.

● Game Zone employees: These are the employees that will be working in the game zone and will
have access to some of the basic database entities like Customer, Waiting List, and collection of
games.

● Developers: They are responsible for the development and working of the Software. In case of
technical difficulties, they will be responsible for solving them.

● Gamers (Customer - Users): They can only view the information related to them such as their
Customer ID, DOB, height, account balance, playing hours, games played, etc.

c. Product Scope

This software intends to make the customer and employee experience of the game zone better. The scope
of this project is:

● Our Game Zone database management service will be useful to manage the data of the games,
customers, their finances, arranging waiting lists of the customers, managing the waiting list, etc.

● This system is built with keeping normal problems like assigning games to the customers,
checking balance in the debit card before registering the game, and checking the required age of
the customer for any particular game.
● This system will be useful to the big Gaming Zones companies as well as small local Game Zones.
it will also be useful to game renting shops. It will also be useful to the individuals who own many
games and want to rent them to others.

● This system will also be useful to the sponsors for organizing game tournaments for online or
offline team games and make it easier to distribute prizes to the winners automatically.

d. Description
● Requirements:

Our system will keep track of all customer data and their balance on their own debit card. We need
a database of all games in a particular game having information about the game, price of the game,
who can play the game, at which time the game is available, the waiting list for a particular game,
and the history of the game that has been played. Each game also has a winner. The game type can
be online or offline.

● The relations that we are planning to implement for this system:-

1) Owner: This relation contains information about the owner of the Game Zone like Owner ID,
Owner Name etc.

2) Manager: This relation has manager ID, manager name etc. details of the managers.

3) Employee: This relation contains information about the employees working in the Game Zone
like Employee ID, Employee Name.

4) Developer: This relation contains information about the developers like Developer ID, Developer
Name etc.

5) Customers: This relation has customer_id, debit card information, Age, Name address of the
customer.

6) Games: This relation has a list of all games with their Game ID, age and height restrictions on
each game, rent of the game, duration of the game, the price for the game, winner of the game,
type_of_game which indicate that game can be played online or offline.

7) Game_History: This relation will have the history of all games and associated customer names.

8) Debit Cards: Debit cards have information about the customer and the balance associated with
each debit card ID.

9) Transaction_History: This contains the debit card number and history of all transactions each
assigned a unique transaction ID.

10) Waiting List: This relation will have a waiting list of all the customers with their waiting number.

11) Customer_activity: This will contain information about which customer is playing which game.
12) Tournament: This relation will contain tournament ID, Tournament Name, Tournament
Type, game_id and the price of the final winners.

● The functions that we are planning to implement for this system:-

1) Add_manager: This function adds a manager into the database.


2) Add_developer: This function adds a developer into the database.
3) Add_employee: This function adds an employee into the database.
4) New_customer_regi: This function will be useful for the registration of new customers.
5) New_game_insert: This function will be useful for adding new games and their details to the
system.
6) Omit_manager: This function will be used to remove a particular manager from the database.
7) Omit_employee: This function will be useful for removing a particular employee from
the database.
8) Omit_developer: This function will be used for removing a particular developer.
9) Omit_customer: This function will be useful for deleting any registered customers.
10) Omit_game: This function will be useful for deleting existing games.
11) Check_age: This function will check if the age of the customer is appropriate for the
selected game.
12) Check_height: This function will check if the height of the customer is appropriate for the
selected game.
13) Auto_assign_debit_card:- Whenever a new customer creates an account in the Game Zone,
a debit card with a unique number and default balance will be assigned to the customer.
14) Update_balance:- Customers can add money to their account if required.
15) Buy_game:- When a customer buys a game or plays a paid game having a certain amount
or makes any purchases, their account balance will be updated or an error message will be
sent automatically.
16) Auto_assign_prize_money:- When a customer wins a game or prize money, the prize amount
is added in their account balance automatically.
17) Reminder_for_waiting_time: When the customer is waiting for a particular game, if the
game slot is free then the customer is notified that he/she can play the game now.
18) Reminder_for_finishing_Game:- Customer is notified 5 minutes before the end of his current
plan for the game.
19) Transfer_balance: Customers will be able to transfer the balance from their debit card from
one to another.
20) View_customer_profile: This function will show all the information available about any
particular customer.
21) Update_customer_profile: This function will be useful to update the information of the
customer.
22) View_Game_List:- It will show the list of all available games.
23) Permission_to_access_and_maintain_database:
Whenever a system crashes or for maintenance of database developer needs to access the database

● Real-World Work Flow of Game Zone


○ An existing customer, who has already registered, may log in to the system. There will
be a separate view for customers so that they can check out their game logs, debit card
balance, pay, and book a slot for a particular game(if slots are available and the
customer has enough balance).
○ If the customer is new, then he/she will be able to register and will be assigned
a customer ID and a debit card.
○ If a customer runs out of money, then he/she has an option to add money to their
account as well.
○ All the money adding/withdrawing transactions of a customer are noted and stored and
can be accessed by the customer.
○ The amount of time a customer plays a game is noted in a log along with the required
details.
○ A customer may also request for an arrangement of a tournament of the desired game.
Once a tournament is arranged and registered, existing customers may register and
take part in the tournament.
○ High scores of games and records are also kept in the database, which is easily accessible
to everyone.
2. Fact-Finding Phase
a. Reading and Description
1. Gaming Zone Management System from http://moizhassan.com/gamingzone.html
From this, we referred to what are the functions and roles that we need to maintain and the
overall relationship between them. In short, we referred to the structure of the database.

2. Games Database Management System, WEB


DBMS Mini Project by Vidyashri M H
https://www.vtupulse.com/web-dbms-mini-project/games-database-management-system From
this article on the web, we understood an already existing Game Database Management system.
From this we learnt what a Game Zone system requires and the points to consider for a smooth
working of the system as well as keeping the customers happy, by focusing on their needs.

3. Database System Concepts, by Abraham Silberschatz, Henry F. Korth, S. Sudarshan

From this article, we understood the DBMS concepts like E-R Model, Database designing etc.

● Combined Requirements gathered from the readings

● A well functioning Database management system is required to maintain and update


all the information about games, customers and the employees.
● A user interface is required so that the customers can easily access the data required
without having to know much about the actual implementation of the system.
● All the basic functionality that is expected to be in a game zone.
○ E.g. Keeping a record of Customers and their balance, games, time slots…etc.
● System administrators and employees will be assigned different roles that will ensure
the security of the sensitive information of the customers.
● System structure and functions should be designed in such a way that it ensures the fast
performance of the system.
● The interface should be clean and without any redundant data.

b. Interview(s)

1. Interview Plan

System: Die Game Zone (DGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Moiz Hassan(Role Play) Designation: CEO at MoizHazzan Game Zone

Interviewer:
1) Yash SakariaDesignation: Business Development Executive

2) Siddharth Rathod Designation: Developer

Date: 5/10/2021 Time: 12:30

Duration: 45 minutes Place: Zoom meeting

Purpose of Interview:

Preliminary meeting to identify problems and requirements regarding security at the MGZ
Pvt Ltd site.

Agenda:

● Introduction and current status


● Initial ideas and follow-up action regarding the security of the system and
resistance against cyber attacks.
● About the needs and complaints of the customers and how you handle those issues.

Documents to be brought to the interview:

● Rough plan of building


● Any documents relating to the current security system and current needs of the
customers.

● Interview Summary

System: Die Game Zone (DGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Moiz Hassan(Role Play) Designation: CEO at MoizHazzan Game Zone

Interviewer:

1) Yash SakariaDesignation: Business Development Executive

2) Siddharth Rathod Designation: Developer

Date: 5/10/2021 Time: 12:30

Duration: 45 minutes Place: Zoom meeting

Purpose of Interview:

Preliminary meeting to identify problems and requirements regarding


security at the MGZ Pvt Ltd site.
Results of the interview:

● Security will also be maintained at the system level so the non-authorized employees will
not be able to access the sensitive information.
● Strict rules will be implemented so that customers will not get games that are not
suitable for their age or height.
● The backup of the database will be taken at regular intervals so that lost information can
be recovered.
● Regular feedback from customers will be taken and improvements will be done to the
system accordingly.
● For the customer requirements that contrast each other, the majority will be taken
into account.

2. Interview Plan

System: Die Game Zone (DGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Zabin Banu(Role Play)

Designation: Developer at MoizHazzan Game Zone

Interviewer:

1) Neel PatelDesignation: Business Development Executive

2) Harshal Mavani Designation: Developer

Date: 6/10/2021 Time: 14:30

Duration: 45 minutes Place: MGZ head Office

Purpose of Interview:

To understand the creation and maintenance of the system at the MGZ Pvt
Ltd site.

Agenda:
● Introduction and current status
● How do you handle updating the database and maintaining the system
● About the ideas for improving the performance of the system
● How you make the website attractive.

Documents to be brought to the interview:

● Rough plan of building


● Any documents relating to the current system, analysis of the performance, and
feedback of the customers.
● Interview Summary

System: Die Game Zone (DGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Zabin Banu(Role Play) Designation: Developer at Die Game Zone

Interviewer:

1) Neel PatelDesignation: Business Development Executive

2) Harshal Mavani Designation: Developer

Date: 5/10/2021 Time: 14:30

Duration: 45 minutes Place: DGZ head Office

Purpose of Interview:

To understand the creation and maintenance of the system at the MGZ Pvt
Ltd site.

Results of the interview:

● After the interview, we got to know that an attractive website plays an important role
in publicity.
● We will increase the performance of the system by efficient implementation and a
well structured system.
● For updating databases, we have to take care that other databases are not
messed up(integrity is maintained).

3. Interview Plan

System: MoizHazzan Game Zone (MGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Nadim khan(Role Play)

Designation: Regular customer at MoizHazzan Game Zone

Interviewer:

1) Neel PatelDesignation: Business Development Executive

2) Harshal Mavani Designation: Developer


Date: 6/10/2021 Time: 14:30

Duration: 45 minutes Place: MoizHazzan Game Zone

Purpose of Interview:

The overall opinion of the game zone, advantages, and drawbacks of the
current system

Agenda:
● Introduction and current status
● What is the overall performance of the current system and if it
is satisfactory or not.
● Things or features that are dissatisfactory or need improvement.
● Things or features that were more likable to the customer.

● Interview Summary

System: MoizHazzan Game Zone (MGZ)

Project Reference: SF/SJ/2021/10

Interviewee:

1) Nadim khan(Role Play) Designation: Regular customer at MoizHazzan Game Zone

Interviewer:

1) Neel PatelDesignation: Business Development Executive

2) Harshal Mavani Designation: Developer

Date: 5/10/2021 Time: 14:30

Duration: 45 minutes Place: MoizHazzan Game Zone

Purpose of Interview:

The overall opinion of the game zone, advantages and drawbacks of


the current system.

Results of the interview:

● The information about popular games


● Likable features like waiting list reminder, transfer balance, etc
● Some security on who can access their details.
● The age group of most of the people in the game zone.
● Combined Requirements gathered from the Interviews
● System administrators and employees will be assigned different roles that will ensure the
security of the sensitive information of the customers. Also, Strict rules will be implemented so
that customers will not get games that are not suitable for their age or height.
● System structure and functions should be designed in such a way that it ensures the fast
performance of the system and for updating databases, we have to take care that other databases
are not messed up(integrity is maintained).
● The interface should be clean and without any redundant data.
● Feedback should be received from the targeted customer groups about different aspects of
the system and suggestions and also likable games.
● The age group that occupies most of the gamezone so that games can be arranged accordingly.
● Likable features like waiting list reminder, transfer balance, etc should be included in the system.
● The backup of the database will be taken at regular intervals so that lost information can be
recovered.

3. Questionnaire(s)

1. Age of the customer:

Intent of this question:


To get to know what the age group of the customers/players is and set the games and the
software User Interface accordingly.
Observation from the response:
The majority of the players will be of the age 16-25, so the software can be designed and
the games can be selected accordingly.

2. Which processor do you prefer on a PC?

The intent of this question:


To get to know what the processor preference of the customers/players is and get the
computers accordingly.

Observation from the response:


The majority of the players prefer Intel processors and hence the PCs should be
purchased accordingly.

3. What do you expect from a good Game Zone?


Intent of this question:
To get to know what type of services do the customers/players expect from the Game Zone.

Observation from the response:


The graph is evenly distributed, hence all the categories should be given equal priority.

4. How often do you need assistance from the employee in a game zone?

1 - Occasionally
5 - Frequently

The intent of this question:


To get to know how often do players require assistance from the staff.
Observation from the response:
The majority of the players don’t require assistance that often from the staff and hence we
can keep less staff for support.

5. What type of games do you expect in a Game Zone?

The intent of this question:


To get to know what games the customers/players prefer.

Observation from the response:

The graph is evenly distributed in terms of game categories and hence the games should be
bought accordingly.

● Combined Requirements gathered from the Questionnaire

1. The Game Zone environment should be made such that it suits the teenage group, moreover, it
should be easy to use as there are users from age group 11-15 who are also using the system.
2. Intel Processors are more preferred in the Gaming PCs by the customers.
3. The software to be developed should have a good UI, have a good collection of games, and
provide quick services.
4. The number of employees working in the Game Zone should be moderate as the majority of
the customers are aware of the software environment.
5. It should have all the current trending games. For that, customer feedback should be taken at
a regular interval of time.
6. There are a few games like GTA that can only be played by someone above a certain age, so
age restrictions must be added.
7. A few arcade games require the players to be of a certain height, which should be specified
and only players matching those criteria should be allowed to register for that particular game.

4. Observation(s)

IT Solutions: Observations

System: MoizHazzan Game Zone

Project Reference: SF/SJ/2021/10

Observations by: Siddharth Rathod

Date: 6/10/2021 Time: 14:30

Duration: 45 minutes Place:MoizHazzan game zone

Observations:

● Real-time updating of all the game reservations was done in the system to ensure that everyone
gets to play the game and the games are used optimally.
● The employee’s role was limited yet important for the proper functioning of the Game Zone.
● Not all data was accessible to everyone, privacy and security of the data were given priority.
● All the trending games were available in the Game Zone visited.
● There was minimal waiting for a game, as enough games were available, more popular
games were available abundantly.
● All the transactions for renting and booking time slots and adding money to the account were done
easily through debit cards provided by the Game Zone.
● Having a proper internet connection is very important.
● Proper age and height restrictions must be enforced.

Combined requirements from Observations:

● The person that belongs to any of the user classes found that this system was necessary to
maintain proper workflow.
● The database is updated in real-time.
● The system should optimize the work of the employees so that customers can receive their
service fast.
● Different user classes should be given different authorization to access or update the system.
● Easy registration process and good User interface to ensure quality experience for the users.
● All the trending games should be made available.
● There should be enough devices and games that satisfy the needs of all customers and
ensure least amount of queueing.
● After choosing the game, the notification will be sent when the waiting list is cleared.
● Users should be able to add a balance to the debit card when the balance is low.
● The winner of the various games should be given prizes directly in their debit card balance.
● The internet and electricity should be maintained 24/7.
● It is important to check the age and height constraints of the game and only allow the
eligible players to play.

3. Fact-Finding Chart

Objective Technique Subject Time


commitment

To get background knowledge on the Background Few similar Projects and 1 day
Game Zone readings requirements of Game Zone

Preliminary meeting to identify Interview 45 minutes


problems and requirements CEO at MoizHazza Game
regarding security at the MGZ Pvt
Ltd site. Zone

To get information about database Interview 45 minutes


updates and other problems faced by Developer at MoizHazza Game
Game Zone. Zone

To get customer feedback on the Interview 45 minutes


system A regular customer at MoizHazzan
Game Zone

To get knowledge of the real world Observations Customers 1 hour


Gaming Zone

To get knowledge of the real world Observations Employees of the Game Zone 1 hour
Gaming Zone

To understand the user’s perspective Questionnaire Student Developers 1 day


4. List of Requirements

1. The Game Zone environment should be made such that it suits the teenage group, moreover, it should
be easy to use as there are users from age group 11-15 who are also using the system. (occurs at
Questionnaire, Interview)
2. Intel Processors are more preferred in the Gaming PCs by the customers. (occurs at questionnaire)
3. The software to be developed should have a good UI, have a good collection of games, and provide
quick services. (occurs at Interview, Observation)
4. The number of employees working in the Game Zone should be moderate as the majority of the
customers are aware of the software environment. (occurs at Questionnaire)
5. It should have all the current trending games. For that, customer feedback should be taken at a regular
interval of time. (occurs at Interview, Observation)
6. There are certain games that must have eligibility criteria like age and height. So, that customer
satisfying those criteria will only be allowed to play those games. (Occurs at Interview, Observation)
7. System administrators and employees will be assigned different roles that will ensure the security of the
sensitive information of the customers. (occurs at Interview, Observation, Background Reading)
8. System structure and functions should be designed in such a way that it ensures the fast performance of
the system. (occurs at Interview, Observation, Background Reading)
9. The interface should be clean and without any redundant data. (occurs at Interview, Background
Reading)
10. Feedback should be received from the targeted customer groups about different aspects of the system
and suggestions. (occurs at Interview)
11. The integrity in different parts of the system should be maintained in real-time. (occurs at
Interview, Observation)
12. The system should optimize the work of the employees so that customers can receive their
service fast. (occurs at Observation)
13. There was minimal waiting for a game, as enough games were available, more popular games
were available abundantly. (occurs at Interview, Observation)
14. The internet and electricity should be maintained 24/7. (occurs at Observation)
15. We should also provide backup for our database. (occurs at Interview)
5. User Classes and Characteristics

● Game Zone owner: They are the admin of the database. They have all the rights and can also add/remove
managers.
● Game Zone manager (User): These will be the main users. They can add/remove customers, update any
information of the users, etc. In short, they are the manager of the database.
● Game Zone employees: These are the employees that will be working in the game zone and will have
access to some of the basic database entities like Customer, Waiting List, and collection of games.
● Developers: They are responsible for the development and working of the Software. In case of technical
difficulties, they will be responsible for solving them.
● Gamers (Customer -Users): They can only view the information related to them such as their account
balance, playing hours, games played, etc.

6. Operating environment

Hardware, software, connectivity requirements


● Gaming Computers (with high processing power)
● High-Speed internet connection (20Mbps or more)
● Headphones, controller/joystick
● Gaming consoles like Xbox and Playstation
● Steam software for games on computers
● Different online and offline games
● Electricity required
● Arcade Games like pinball games and merchandise games
● Equipment required for VR games

7. Product Functions

All functions that are supported by PostgreSQL will be implemented. For example multi querying,
plotting of data related to the properties of the table used, and real-time analytics of a number of people
accessing/using/visiting the cloud-integrated DBMS service.

Following are the details of the functions that we have implemented in our DBMS.

1. Add_manager: This function adds a manager into the database.


Input: Name, ID and relevant details of the manager.
Process: If the manager does not exist, then (s)he will be added to the database.
Output: Manager added successfully!!

2. Add_developer: This function adds a developer into the database.


Input: Name, ID and relevant details of the developer.
Process: If the developer does not exist, then (s)he will be added to the database.
Output: Developer added successfully!!

3. Add_employee: This function adds an employee into the database.


Input: Name, ID and relevant details of the employee.
Process: If the employee does not exist, then (s)he will be added.
Output: Employee added successfully!!

4. New_customer_regi:- This function will be useful for the registration of new customers.
Input: Name and relevant details of the customer are filled by the employee/manager/admin.
Process: If the customer does not exist, then (s)he will be added to the customer relationship.
Output: Customer added successfully!!

5. New_game_insert:- This function will be useful for adding new games and their details to
the system.
Input: Name and relevant details of the game are filled by the employee/manager/admin.
Process: If the game does not exist, then it will be added to the game’s relation.
Output: Game added successfully!!
6. Omit_manager: This function will be used to remove a particular manager from the database.
Input: Manager ID is taken as input.
Process: If the manager ID exists, then it will remove that particular manager from the database.
Output: Manager removed successfully!!

7. Omit_employee: This function will be useful for removing a particular employee from
the database.
Input: Employee ID is taken as input.
Process: If the employee ID exists then it removes the particular employee from the database.
Output: Employee removed successfully.

8. Omit_developer: This function will be used for removing a particular developer.


Input: Developer ID is taken as an input.
Process: If the developer ID exists then it removes the particular employee from the database.
Output: Developer removed successfully!!

9. Omit_customer:- This function will be useful for deleting any registered customers.
Input: The ID of the customer is filled by the employee/manager/admin.
Process: The customer will be deleted from the customer relationship.
Output: Customer removed successfully!!

10. Omit_game:- This function will be useful for deleting existing games.
Input: The ID of the game is filled by the employee/manager/admin.
Process: The game will be deleted from the game’s relation.
Output: Game removed successfully!!

11. Check_age:- This function will check if the age of the customer is appropriate for the
selected game.
Input: The age of the customer.
Process: Checks for the age eligibility for a particular game.
Output: boolean (Yes/No) answer based on which the customer will be allotted a particular game.

12. Check_height:- This function will check if the height of the customer is appropriate for
the selected game.
Input: The height of the customer.
Process: Checks for the height eligibility for a particular game.
Output: boolean (Yes/No) answer based on which the customer will be allotted a particular game.

13. Auto_assign_debit_card:- Whenever a new customer creates an account in the Game Zone, a
debit card with a unique number and default balance(zero rupees) will be assigned to the
customer. Input: The customer ID of the new customer.
Process: A new debit card will be added to the debit card in relation to the appropriate balance.
Output: Debit card has been assigned to the customer.

14. Update_balance:- Customers can add money to their account if required.


Input: The amount of money the customer needs to add.
Process: Atomically updates the customer balance.
Output: Money added successfully! Also shows the final account balance.

15. Buy_game:- When a customer buys a game or plays a paid game or makes any purchases, their
account balance will be updated or an error message will be sent automatically.
Input: The game ID and Customer ID
Process: The price of the game will be deducted from the customer debit card balance and the
customer will be added to the waiting list. but if the balance is lower than the price, then an error
message will be sent.
Output: Purchase successful/Insufficient balance.

16. Auto_assign_prize_money:- When a customer wins a game or prize money, the prize amount
is added to their account balance automatically.
Input: Tournament ID and customer ID
Process: The price money will be added to the debit card balance of the customer accordingly.
Output: Once successful of assigning prize money then the customer is notified that he/she will
win this amount of money.

17. Reminder_for_waiting_time:- When the customer is waiting for a particular game, if the game
slot is free then the customer is notified that he/she can play the game now.
Input: When a customer is waiting for the game, the customer is added to the waiting list.
Process: Availability of computer and slot is updated on some interval of time.
Output: Customer is notified that he/she can play the game now.

18. Reminder_for_finishing_Game:- Customer is notified 5 minutes before the end of his current
plan for the game.
Input: The timer is started when the customer starts playing the game.
Process: The timer continues to run in real-time.
Output: once the timer has reached the cutoff the customer is notified your current plan will
finish in 5 minutes.

19. Transfer_balance:- Customers will be able to transfer the balance from their debit card from
one to another.
Input: Customer must be login using their account to transfer money to another, (s)he also needs
the debit card number or customer id for transferring money into his/her account and also provide
how much amount of money to be transferred.
Process: The amount of money transferred is deducted from the donner customer and money
should be added to another customer’s account.
Output: If there is a successful transfer of money then the customer is notified that money has
been transferred successfully. If there is some system failure of hardware or software then the
customer is notified that the transaction failed, try again.

20. View_customer_profil:- This function will show all the information available about any
particular customer.
Input:- Student ID
Process:- The information will be taken from the customer relationship based on the input
customer ID and balance from the debit card relation
Output:- The information about customers and balance in their debit card

21. Update_customer_profil:- This function will be useful to update the information of the
customer.
Input:- Customer ID and new customer detail
Process:- The customer details will be updated in customer relation
Output:- The information has been updated

22. Permission_to_access_and_maintain_database:-
Whenever a system crashes or for maintenance of database developer needs to access the database
and
Input:- Username and password for accessing the database.
Process:- Identity is verified then the developer can modify the code and test the system.
Output:- Updated System.

23. View_Game_List:- It will show the list of all available games.


Input:- This function has no input (void).
Process:- It will go through all the games and check if it is available at that moment or not.
Output:- List of all games that are available at present time.

24. Different functions are responsible for maintaining integrity.


8. Privileges

● List of the user-class:


1. Gamer
2. Employee
3. Developer
4. Manager
5. Owner

● List of the functions which can be used by different user classes:


1. Gamer:-
a. New_customer_regi
b. Transfer_balance
c. View_customer_profil (can only call for his/her profile)
d. Buy_game
e. Check_height
f. Check_age
g. Update_balance
h. View_Game_List

2. Employee:-
a. Omit_game
b. Omit_customer
c. New_game_insert
d. Buy_game
e. Auto_assign_debit_card
f. Reminder_for_finishing_Game
g. Reminder_for_waiting_time
h. All the functions that can be accessed by the customer

3. Developer:-
a. Permission_to_access_and_maintain_database
b. All the functions that can be accessed by the customer and employee

4. Manager:-
a. Add_developer
b. Omit_developer
c. Add_employee
d. Omit_employee
e. All the functions that can be accessed by the customer, employee and developer

5. Owner:- Owner has all access to Game Zone.


a. Add_manager
b. Omit_manager
c. All the functions that can be accessed by the customer, employee, developer,
and manager
9. Assumption

● It is assumed that the game zone has all equipment and games in working condition.
● All customers and employees have their user ID and passwords which are encrypted and cannot be hacked.
● All customers play only in their allotted time and don’t play for extra or less time.
● No customers are given priority on the waiting list of the games.
● Once registered for a game the customer doesn’t cancel that registration and plays the game.
● All the games played have fair results and leaderboards which are updated by the employees of the Game
Zone.

10. Business Constraints

● All the games played are in real-time, the registration process and time allocation process should
occur instantly and be updated in real-time to ensure the smooth running of the Game Zone.
● The amount of games, hardware, and computing power available is limited.
● The capacity of the Game Zone, that is the number of players that can play games in parallel, is limited.
Section 2: Noun Analysis

1. Noun Analysis
2. Entity-Attribute
3. Rejected Nouns
4. Rejected Verbs
1. Noun Analysis

Sr. No. Noun Verbs

1 data document

2 game create

3 zone employees will

4 account balance make

5 list work

6 management system be

7 intended audience keep

8 reading suggestions track

9 zone owner list

10 add/remove managers provide

11 zone manager fast

12 user access

13 main users allow

14 add/remove customers view

15 game zone modify

16 basic database entities guide

17 customer have

18 waiting list can

19 developers add

20 software remove

21 technical difficulties update

22 gamers short
23 account balance like

24 product scope case

25 employee experience scope

26 zone database management service manage

27 normal problems debit

28 debit card Derive_age

29 particular game rent

30 game tournaments distribute

31 offline team games need

32 description requirements play

33 customer data type

34 particular game implement

35 game type indicate

36 id log

37 manager name separate

38 relation contains information check

39 debit card information pay

40 age register

41 name request

42 age restrictions take

43 game_history serves

44 customer name finances

45 debit_history creates

46 debit card number buys


47 realtime_playing purchases

48 online_game_tournament runs

49 final winners scores

50 auto_assign_debit_card records

51 whenever Required_age

52 new customer creates assigned

53 Unique debit card number updated

54 default balance noted

55 update_balance stored

56 auto_balance_deduction desired

57 account balance arranged

58 auto_assign_prize_money Waiting

59 prize money

60 real-world

61 flow

62 separate view

63 game logs

64 debit card balance

65 particular game

66 high scores

67 Date of Birth

68 height

69 Waiting no

70 Customer ID
71 Game ID

72 Rent Rate

73 Height Restriction

74 Duration

75 Employee ID

76 Employee Name

77 Owner ID

78 Developer ID

79 Developer Name

80 Transaction History

81 Transaction ID

82 Debit card ID

83 time

84 Amount

85 Type

86 Customer Activity

87 Prizes

88 Tournament Activity

89 Tournament ID

90 Tournament Name
2. Entity-Attribute:

Sr. No Candidate Entity Set Candidate Attribute set Candidate Relationship set
1. Customer Customer ID, Customer Name, Debit waits, plays, registers, assigns
Card Number, Date of Birth, age,
height, Address
2. Debit card Debit card ID, Account balance, Assigns

3. Game Game ID, Game name, Game type, Age waits, plays, takes
restriction, Rent Rate, Height
Restriction, Duration
4. Employee Employee ID, Employee Name

5. Manager Manager ID, Manager Name

6. Owner Owner ID, Owner Name

7. Developer Developer ID, Developer Name

8. Transaction History Transaction ID, Debit card ID, time, records


Amount
9. Tournament Tournament ID, Tournament Name, Takes, registers
Prizes, Type, Game ID
10. Game_History Time, isPlaying Plays
3. Rejected Nouns:

Sr. No. Noun Reject Reason

1 data General

2 account balance Attribute

3 list General

4 management system General

5 intended audience Irrelevant

6 reading suggestions Irrelevant

7 add/remove managers Association

8 user Duplicate

9 main users Duplicates

10 add/remove customers Association

11 game zone General

12 basic database entities Vague

13 software Irrelevant

14 technical difficulties Vague

15 gamers Duplicates

16 account balance Attribute

17 product scope irrelevant

18 employee experience irrelevant

19 zone database management service General

20 normal problems Vague

21 particular game General


22 offline team games Attribute

23 description requirements Vague

24 customer data General

25 particular game Duplicate

26 game type Attributes

27 id Attributes

28 manager name Attributes

29 relation contains information Vague

30 debit card information General

31 age Attributes

32 name Attributes

33 age restrictions Attributes

34 game_history Attributes

35 customer name Attributes

36 debit_history Attributes

37 debit card number Attributes

38 realtime_playing Attributes

39 auto_assign_debit_card Associations

40 whenever Vague

41 new customer creates Associations

42 Unique debit card number Attributes

43 default balance Attributes

44 update_balance Associations

45 auto_balance_deduction Associations
46 account balance Attributes

47 auto_assign_prize_money Associations

48 prize money Attributes

49 real-world General

50 flow Vague

51 separate view Irrelevant

52 game logs Association

53 debit card balance General

54 high scores Association

4. Rejected Verbs:

Verbs Reject reason

document General

will General

make General

work General

be General

provide General

fast Vague

have General

can General

short Vague

like Vague
case General

scope General

manage General

distribute Irrelevant

need Vague

play General

type Irrelevant

implement Irrelevant

indicate Irrelevant

separate Irrelevant

pay Duplicate

request Vague

take Vague

buys Duplicate

purchases Duplicate

Runs Irrelevant
Section 3: ER-Diagrams all versions.

1. ER Diagram Version 1
2. ER Diagram Version 2
3. ER Diagram Version 2 (Final)
4. Relationship Types
1. ER Diagram Version 1
2. ER Diagram Version 2

*Note - Here 1 and N on the relationship indicates one and many respectively
3. ER Diagram Version 2 (Final)

Note - Here a weak entity named game_history is added, where plays is the identifying ternary
relationship, Customer and Game are identifying entity sets.
The cardinality of each relationship set is mentioned in the ER diagram itself.

Relationship Types
1. Binary Relationships
a. Waits
b. Plays
c. Registers
d. Record
e. Assign
f. Takes
2. Ternary Relationships

a. Plays
Section 4 : Conversion of Final
ER-Diagram to Relational
Model.

1. Relational Model Diagram Version 1


2. All the Relations
1. Relational Model Diagram Version 1:
2. All the relations

● Debit card(Debit card ID, Account, Balance)


● Customer(CustomerID, CustomerName, Debit card ID, DOB, Age(), Height, HouseNo, StreetNo,
City, Country, Pincode)
○ FK Debit card ID references to Debit card
● Game(GameID, GameName, GameType, AgeRest, HeightRest, Rate, Duration)
● Contact No(CustomerID, Mobile No)
○ FK CustomerID references to Customer
● Waits(CustomerID, GameID, Time)
○ FK CustomerID references to Customer
○ FK GameID references to Game
● Game History(Customer ID, GameID, Time, isPlaying)
○ FK CustomerID references to Customer
○ FK GameID references to Game
● Tournament(TournamentID, TournamentName, TournamentType, Prize)
● Registers(CustomerID, TournamentID)
○ FK CustomerID references to Customer
○ FK TournamentID references to Tournament
● Takes(GameID, TournamentID)
○ FK GameID references to Game
○ FK TournamentID references to Tournament
● TransactionHistory(TransactionID, Debit Card ID, Amount, Time)
○ FK Debit Card ID references to Debit Card
● Owner(OwnerID, OwnerName)
● Developer(DeveloperID,DeveloperName)
● Manager(ManagerID, ManagerName)
● Employee(EmployeeID, EmployeeName)
Section 5: Normalization and
Schema Refinement

1. Functional Dependencies
2. Redundancy and Analysis
3. Normalization upto 3NF/BCNF
4. Final Relational Schema
a. List all final Relations & Schemas with all details
1. Functional Dependencies

● Debit card(Debit card ID → Account, Debit card ID → Balance)


● Customer(CustomerID → CustomerName, CustomerID → Debit card ID, CustomerID → DOB,
CustomerID → Age, CustomerID → Height, CustomerID → HouseNo, CustomerID → StreetNo,
CustomerID → City, CustomerID → Country, CustomerID → Pincode, City → Pincode, Country
→ Pincode)
● Game(GameID → GameName, GameID → GameType, GameID → AgeRest, GameID
→ HeightRest, GameID → Rate, GameID → Duration)
● Contact No: No dependencies
● Waits((CustomerID, GameID) → Time)
● Game History: No dependencies
● Tournament(TournamentID → TournamentName, TournamentID →
TournamentType, TournamentID → Prize)
● Registers: No dependencies
● Takes: No dependencies
● TransactionHistory(TransactionID → Debit Card ID, TransactionID → Amount, TransactionID
→ Time)
● Owner(OwnerID → OwnerName)
● Developer(DeveloperID → DeveloperName)
● Manager(ManagerID → ManagerName)
● Employee(EmployeeID → EmployeeName)

2. Redundancy and Analysis

● Debit card(Debit card ID, Account, Balance)


○ There can be the same balance associated with multiple Debit_card_id
○ There are no transitive dependencies.
● Customer(CustomerID, CustomerName, Debit card ID, DOB, Age, Height, HouseNo,
StreetNo, City, Country, Pincode)
○ FK Debit card ID references to Debit card.
○ Redundancy: Here we have transitive dependency because of (CustomerID → DOB
and DOB→ Age implies CustomerID → Age).
○ Redundancy: Here we have transitive redundancy because of
(CustomerID → City, City → Country, City → Pincode implies CustomerID → Pincode)
○ We removed attributes: DOB, City, and Country. So, now there are no
transitive dependencies.
○ There are no anomalies in this entity.

● Game(GameID, GameName, GameType, AgeRest, HeightRest, Rate, Duration)


○ Redundancy: There can be multiple games of the same GameType,
AgeRest, HeightRest, Rate, Duration.
○ There are no transitive dependencies.

● Contact No(CustomerID, Mobile No)


○ FK CustomerID references to Customer
○ There are no transitive dependencies.
● Waits(CustomerID, GameID, Time)
○ Redundancy: Multiple (CustomerID, GameID) pairs can have the same value of time
attribute.
○ FK CustomerID references to Customer
○ FK GameID references to Game
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Game History(Customer ID, GameID, Time, isPlaying)


○ FK CustomerID references to Customer
○ FK GameID references to Game
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Tournament(TournamentID, TournamentName, TournamentType, Prize)


○ Redundancy: There can be multiple tournaments with the same Tournament types
and prizes.
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Registers(CustomerID, TournamentID)
○ FK CustomerID references to Customer
○ FK TournamentID references to Tournament
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Takes(GameID, TournamentID)
○ FK GameID references to Game
○ FK TournamentID references to Tournament
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● TransactionHistory(TransactionID, Debit Card ID, Amount, Time)


○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Owner(OwnerID, OwnerName)
○ Redundancy: There can be the same name associated with different OwnerID
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Developer(DeveloperID,DeveloperName)
○ Redundancy: There can be same name associated with different DeveloperID
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Manager(ManagerID, ManagerName)
○ Redundancy: There can be the same name associated with the different ManagerID
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

● Employee(EmployeeID, EmployeeName)
○ Redundancy: There can be the same name associated with the different EmployeeID
○ There are no transitive dependencies.
○ There are no anomalies in this entity.

3. Normalization upto 3NF/BCNF

● Debit card(Debit card ID, Account, Balance)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (Debit_card_id) in the candidate key and only one candidate
key. There are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Customer(CustomerID, CustomerName, Debit card ID, Age, Height, HouseNo,


StreetNo, Pincode)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (CustomerID) in the candidate key and only one candidate
key. There are no partial dependencies. Hence, it is in 2NF form.

● Game(GameID, GameName, GameType, AgeRest, HeightRest, Rate, Duration)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute in the candidate key (GameID or GameName). So, there are
no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies that it is in 3NF form.

● Contact No(CustomerID, Mobile No)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 candidate key (CustomerID, Mobile_No). There are no non-
prime attributes in the schema. Hence, it is in 2NF form.
○ There are no functional dependencies. Hence, it is in 3NF form.

● Waits(CustomerID, GameID, Time)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 candidate key (CustomerID, GameID). There are no non-prime
attributes that are dependent on a part of the candidate key. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.
● Game History(Customer ID, GameID, Time, isPlaying)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 candidate key (CustomerID, GameID, Time, isPlaying). There are
no non-prime attributes. Hence, it is in 2NF form.
○ There are no functional dependencies. Hence, it is in 3NF form.

● Tournament(TournamentID, TournamentName, TournamentType, Prize)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (TournamentID) in the candidate key and only one
candidate key. So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Registers(CustomerID, TournamentID)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 candidate key (CustomerID, TournamentID). There are no non-
prime attributes. Hence, it is in 2NF form.
○ There are no functional dependencies. Hence, it is in 3NF form.

● Takes(GameID, TournamentID)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 candidate key (GameID, TournamentID). There are no non-
prime attributes. Hence, it is in 2NF form.
○ There are no functional dependencies. Hence, it is in 3NF form.

● TransactionHistory(TransactionID, Debit Card ID, Amount, Time)


○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (TransactionID) in the candidate key and only one candidate
key. So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Owner(OwnerID, OwnerName)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (OwnerID) in the candidate key and only one candidate key.
So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Developer(DeveloperID,DeveloperName)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (DeveloperID) in the candidate key and only one candidate
key. So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Manager(ManagerID, ManagerName)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (ManagerID) in the candidate key and only one candidate
key. So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.

● Employee(EmployeeID, EmployeeName)
○ This schema does not have any composite or multivalued attribute. It satisfies
atomicity. Hence, it is already in 1NF form.
○ There is only 1 attribute (EmployeeID) in the candidate key and only one candidate
key. So, there are no partial dependencies. Hence, it is in 2NF form.
○ All the functional dependencies have a candidate key on the left side. So, it is in BCNF
form which implies it is 3NF form.
4. Final Relational Schema

List all final Relations & Schemas with all details (final Design of Database)

● Debit card(Debit card ID, Account, Balance)


● Customer(CustomerID, CustomerName, Debit card ID, Age, Height, HouseNo, StreetNo, Pincode)
○ FK Debit card ID references to Debit card
● Game(GameID, GameName, GameType, AgeRest, HeightRest, Rate, Duration)
● Contact No(CustomerID, Mobile No)
○ FK CustomerID references to Customer
● Waits(CustomerID, GameID, Time)
○ FK CustomerID references to Customer
○ FK GameID references to Game
● Game History(Customer ID, GameID, Time, isPlaying)
○ FK CustomerID references to Customer
○ FK GameID references to Game
● Tournament(TournamentID, TournamentName, TournamentType, Prize)
● Registers(CustomerID, TournamentID)
○ FK CustomerID references to Customer
○ FK TournamentID references to Tournament
● Takes(GameID, TournamentID)
○ FK GameID references to Game
○ FK TournamentID references to Tournament
● TransactionHistory(TransactionID, Debit Card ID, Amount, Time)
○ FK Debit Card ID references to Debit Card
● Owner(OwnerID, OwnerName)
● Developer(DeveloperID,DeveloperName)
● Manager(ManagerID, ManagerName)
● Employee(EmployeeID, EmployeeName)
Section 6: SQL Final DDL Scripts, Insert
statements, 40 SQL Queries with
Snapshots of output of each query

1. DDL Scripts
2. Snapshots of Table
3. SQL Queries
1. DDL Scripts:

1. Debitcard

CREATE TABLE IF NOT EXISTS gamezone.debitcard


(
debitcard_id bigint NOT NULL,
account bigint NOT NULL,
balance bigint NOT NULL,
PRIMARY KEY (debitcard_id)
);

2. Customer

CREATE TABLE IF NOT EXISTS gamezone.customer


(
customer_id bigint NOT NULL,
customer_name character varying,
debitcard_id bigint unique,
age bigint,
height bigint,
house_no bigint,
street_no bigint,
pin_code bigint,
PRIMARY KEY (customer_id),
FOREIGN KEY (debitcard_id)
REFERENCES gamezone.debitcard (debitcard_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER before_customer


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.customer
FOR EACH ROW
EXECUTE FUNCTION gamezone.new_debit_card();
3. Game

CREATE TABLE IF NOT EXISTS gamezone.game


(
game_id bigint NOT NULL,
game_name character varying,
game_type character varying,
age_rest bigint CHECK (age_rest>0),
height_rest bigint CHECK (height_rest>0),
rate bigint CHECK (rate>=0),
duration bigint CHECK (duration>0),
PRIMARY KEY (game_id),
CHECK (game_type in ('RPG','FPS','Racing','Open World','Arcade','Other'))
);

4. Contact No

CREATE TABLE IF NOT EXISTS gamezone.contact_no


(
customer_id bigint NOT NULL,
mobile_no bigint NOT NULL,
PRIMARY KEY (customer_id, mobile_no),
FOREIGN KEY (customer_id)
REFERENCES gamezone.customer (customer_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_mn


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.contact_no
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_mobile();

5. Waits

CREATE TABLE IF NOT EXISTS gamezone.waits


(
customer_id bigint NOT NULL,
game_id bigint NOT NULL,
"time" time with time zone,
PRIMARY KEY (customer_id, game_id),
FOREIGN KEY (customer_id)
REFERENCES gamezone.customer (customer_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID,
FOREIGN KEY (game_id)
REFERENCES gamezone.game (game_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_wait_cid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.waits
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_cid();

CREATE TRIGGER check_wait_gid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.waits
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_gid();

6. Game History

CREATE TABLE IF NOT EXISTS gamezone.game_history


(
customer_id bigint NOT NULL,
game_id bigint NOT NULL,
"time" date NOT NULL,
is_playing boolean NOT NULL,
PRIMARY KEY (customer_id, game_id, "time",
is_playing), FOREIGN KEY (customer_id)
REFERENCES gamezone.customer (customer_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID,
FOREIGN KEY (game_id)
REFERENCES gamezone.game (game_id) MATCH
SIMPLE ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_gh_cid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.game_history
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_cid();

CREATE TRIGGER check_gh_gid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.game_history
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_gid();

7. Tournament

CREATE TABLE IF NOT EXISTS gamezone.tournament


(
tournament_id bigint NOT NULL,
tournament_name character varying,
tournament_type character varying CHECK (tournament_type in
('solo','duo','squad')), prize bigint CHECK (prize>=0),
PRIMARY KEY (tournament_id)
);

8. Registers

CREATE TABLE IF NOT EXISTS gamezone.registers


(
customer_id bigint NOT NULL,
tournament_id bigint NOT NULL,
PRIMARY KEY (customer_id, tournament_id),
FOREIGN KEY (customer_id)
REFERENCES gamezone.customer (customer_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID,
FOREIGN KEY (tournament_id)
REFERENCES gamezone.tournament (tournament_id) MATCH
SIMPLE ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_regi_cid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.registers
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_cid();

CREATE TRIGGER check_regi_tid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.registers
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_tid();

9. Takes

CREATE TABLE IF NOT EXISTS gamezone.takes


(
game_id bigint NOT NULL,
tournament_id bigint NOT NULL,
PRIMARY KEY (game_id, tournament_id),
FOREIGN KEY (game_id)
REFERENCES gamezone.game (game_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID,
FOREIGN KEY (tournament_id)
REFERENCES gamezone.tournament (tournament_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_takes_gid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.takes
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_gid();

CREATE TRIGGER check_takes_tid


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.takes
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_tid();

10. TransactionHistory

CREATE TABLE IF NOT EXISTS gamezone.transaction_history


(
transaction_id bigint NOT NULL,
debitcard_id bigint NOT NULL,
amount bigint,
"time" timestamp with time zone,
PRIMARY KEY (transaction_id),
FOREIGN KEY (debitcard_id)
REFERENCES gamezone.debitcard (debitcard_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID
);

CREATE TRIGGER check_th


BEFORE INSERT OR DELETE OR UPDATE
ON gamezone.transaction_history
FOR EACH ROW
EXECUTE FUNCTION gamezone.check_valid_balance();

CREATE TRIGGER update_th_balance


AFTER INSERT OR DELETE OR UPDATE
ON gamezone.transaction_history
FOR EACH ROW
EXECUTE FUNCTION gamezone.update_balance();

11. Owner

CREATE TABLE IF NOT EXISTS gamezone.owner


(
owner_id bigint NOT NULL,
owner_name character varying,
PRIMARY KEY (owner_id)
);
12. Developer

CREATE TABLE IF NOT EXISTS gamezone.developer


(
developer_id bigint NOT NULL,
developer_name character varying,
PRIMARY KEY (developer_id)
);

13. Manager

CREATE TABLE IF NOT EXISTS gamezone.manager


(
manager_id bigint NOT NULL,
manager_name character varying,
PRIMARY KEY (manager_id)
);

14. Employee

CREATE TABLE IF NOT EXISTS gamezone.employee


(
employee_id bigint NOT NULL,
employee_name character varying,
PRIMARY KEY (employee_id)
);
2. Snapshots of Table
● Debit card(Debit card ID, Account, Balance)

● Customer(CustomerID, CustomerName, Debit card ID, Age, Height, HouseNo,


StreetNo, Pincode)
● Game(GameID, GameName, GameType, AgeRest, HeightRest, Rate, Duration)

● Contact No(CustomerID, Mobile No)


● Waits(CustomerID, GameID, Time)

● Game History(Customer ID, GameID, Time, isPlaying)


● Tournament(TournamentID, TournamentName, TournamentType, Prize)

● Registers(CustomerID, TournamentID)
● Takes(GameID, TournamentID)

● TransactionHistory(TransactionID, Debit Card ID, Amount, Time)


● Owner(OwnerID, OwnerName)

● Developer(DeveloperID,DeveloperName)
● Manager(ManagerID, ManagerName)

● Employee(EmployeeID, EmployeeName)
3. SQL Queries:

1. Select all customer names and customer IDs whose name begins with the letter ‘A’.

select customer_name, customer_id


from gamezone.customer
where customer_name like 'A%';

2. Display the waitlist of the customer with customer ID 5.

select *
from gamezone.waits
where customer_id=5;
3. Display all the Game names and Game IDs with game type RPG

select game_name, game_id


from gamezone.game
where game_type='RPG';

4. Display all owner’s names.

select owner_name
from gamezone.owner;
5. Display all employee names whose name consists of exactly 5 characters.

select employee_name
from gamezone.employee
where employee_name like '_____';

6. Display the number of employees at GameZone.

select count(employee_id)
from gamezone.employee;
7. Display all-tournament names whose tournament type is squad.

select tournament_name
from gamezone.tournament
where tournament_type='squad';

8. Display all the Contact numbers of customer with customer id 22.

select mobile_no
from gamezone.contact_no
where customer_id=22;
9. Display the number of games played in the tournament with tournament id.

select tournament_id, count(game_id) as c1


from gamezone.takes
group by tournament_id
order by c1 desc

10. Display all customer IDs that have registered for tournament ID 87.

select customer_id
from gamezone.registers
where tournament_id=87;
11. The customers whose age is between 15 and 20.
select customer_name
from gamezone.customer
where age between 15 and 30;

12. Display the number of customers played in the year 2020.


select count(distinct customer_id)
from gamezone.game_history
where "time" between '2020-01-01 00:00:01' and '2020-12-31 23:59:59';
13. Display the mean balance of all customers.
select sum(balance)/count(*)
from gamezone.debitcard;

14. Display the tournament name having the second highest amount of prize money.
select tournament_name
from gamezone.tournament
order by prize desc offset 1 limit 1;
15. Display all the game names along with their rates sorted in ascending order.
select game_name, rate
from gamezone.game
order by rate;

16. Display the number of transactions done in the year 2021.


select count(transaction_id)
from gamezone.transaction_history
where "time" between '2021-01-01 00:00:01' and '2021-12-31 23:59:59';
17. Display the customer names from ‘Gujarat’.
select customer_name
from gamezone.customer
where pin_code between 360000 and 399999;

18. Display the sum of prizes of all tournaments.


select sum(prize)
from gamezone.tournament;
19. Display Tournament names having tournament type as ‘duo’.
select tournament_name
from gamezone.tournament
where tournament_type = 'duo';

20. Display Game Name having Game Type as Open World and played by
customers having age greater than 18.
select game_name
from gamezone.game
where game_type='Open World' and age_rest>18;
21. Display the name of Game that is played by most customers.

select game_name
from gamezone.game
where game_id =
( select game_id
from gamezone.game_history
group by game_id
order by count(customer_id) desc limit 1 );
22. Display customer name and their account balance sorted with the balance from
high to low.
select customer_name, balance
from gamezone.customer join gamezone.debitcard on
customer.debitcard_id=debitcard.debitcard_id order by balance desc;

23. Show all transactions of the customer with customer_id 55.


select transaction_id, amount, "time"
from gamezone.customer natural join
gamezone.transaction_history where customer_id=55;
24. Show the clear balance of the customer with customer_id 55.

select customer_name, balance


from gamezone.customer natural join gamezone.debitcard
where customer_id=55;

25. Display all the game names with the minimum cost.
select game_name
from gamezone.game
where rate = ( select min(rate)
from gamezone.game);
26. Display the tournament names with the highest prize.

select tournament_name
from gamezone.tournament
where prize= (select max(prize)
from gamezone.tournament);

27. Display all customer names who haven’t been given their phone number.

select customer_id, customer_name


from gamezone.customer
where customer_id not in (select customer_id
from gamezone.contact_no);
28. Show the transaction History and customer name having the maximum balance.

select customer_name, transaction_id, amount, "time"


from (gamezone.customer natural join gamezone.debitcard) natural join gamezone.transaction_history
where balance=(select max(balance)
from gamezone.debitcard);
29. Display tournament name which has the maximum number of customers
registered for it.
select tournament_name
from gamezone.tournament
where tournament_id=(select tournament_id
from gamezone.registers
group by tournament_id
order by count(customer_id) desc limit 1);

30. Display all the game names that are being played in the tournament with ID 68.
select game_name
from gamezone.game natural join gamezone.takes
where tournament_id=68;
31. Display the customer name and customer id who plays in the year 2020.
select distinct customer_name
from gamezone.game_history natural join gamezone.customer
where "time" between '2020-01-01 00:00:01' and '2020-12-31 23:59:59';
32. Display the customer name, customer id, and no of transactions of the customer
who has a maximum transaction.
select customer_name, customer_id, count(transaction_id) as no_of_transactions
from gamezone.transaction_history natural join gamezone.customer
group by debitcard_id, customer_name, customer_id having
count(transaction_id) = (select count(transaction_id)
from gamezone.transaction_history
group by debitcard_id
order by count(transaction_id) desc limit 1);

33. Display the customer name who has played the most number of games.
select customer_name
from gamezone.customer natural join gamezone.game_history
group by customer_name
having count(game_id) = (select count(game_id)
from gamezone.customer natural join gamezone.game_history
group by customer_name
order by count(game_id) desc limit 1);
34. Display all the customers' names who are not eligible to play the game with game
ID equal to 10.
select customer_name
from gamezone.customer
where (customer.age,customer.height)<(select
age_rest,height_rest from gamezone.game
where game.game_id=10;
35. Display the customer name who has played games for maximum time duration.
select customer_name
from (gamezone.customer natural join gamezone.game_history) natural join
gamezone.game group by customer_name
having sum(duration) = (select sum(duration)
from (gamezone.customer natural join gamezone.game_history) natural
join gamezone.game
group by customer_name
order by sum(duration) desc limit 1);

36. Display the game name which has maximum height restriction.
select game_name
from gamezone.game
where height_rest = (select height_rest
from gamezone.game
order by height_rest desc limit 1);
37. Display the customer names along with the number of transactions done by them.
select customer_name, count(transaction_id) as no_of_transaction
from (gamezone.customer natural join gamezone.transaction_history) natural join gamezone.debitcard
group by customer_name
order by customer_name;
38. Display Customer name along with theTournament id, Tournament name in which
he/she has participated and also display the Game name that he/she played in that
tournament.
create or replace view v2 as
select tournament_name, game_name
from (gamezone.tournament natural join gamezone.takes) natural join gamezone.game;

select customer_name, tournament_id, tournament_name, game_name


from (gamezone.customer natural join gamezone.registers) natural join v2
where customer_id=11;

39. Display the customer names which are the oldest.


select customer_name
from gamezone.customer
where age = ( select age
from gamezone.customer
order by age desc limit 1);
40. Display the customer names, debit card id, balance and phone numbers who
have an account balance less than 5000.
select customer_name, debitcard_id, balance, mobile_no
from (gamezone.customer natural join gamezone.debitcard) natural join
gamezone.contact_no where balance < 5000;
Section 7: Project Code with
output screenshots
1. Backend Code
2. Screenshots of the Website that connects the Database.
1. Backend Code:

These are some of the code snippets.

Connects frontend with backend (Using Django):

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'OPTIONS': {
'options': '-c search_path=gamezone'
},
'NAME': 'gamezone',
'USER': 'postgres',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}

Code for setting up the URL:

urlpatterns = [
path('admin/', admin.site.urls),
path('sortGame',views.sortGame,name="sortGame"),
path('showGame',views.showGame,name="showGame"),
path('insertGame',views.insertGame,name="insertGame"),
path('editGame/<int:id>',views.editGame,name="editGame"),
path('',views.HomePage,name="HomePage"),
path('updateGame/<int:id>',views.updateGame,name="updateGame"),
path('delGame/<int:id>',views.delGame,name="delGame"),
path('deletedGame/<int:id>',views.deletedGame,name="deletedGame"),
path('runQueryGame',views.runQueryGame,name="runQueryGame"),

path('showCustomer',views.showCustomer,name="showCustomer"),
path('insertCustomer',views.insertCustomer,name="insertCustomer"),
path('sortCustomer',views.sortCustomer,name="sortCustomer"),
path('editCustomer/<int:id>',views.editCustomer,name="editCustomer"),
path('updateCustomer/<int:id>',views.updateCustomer,name="updateCustomer"),
path('delCustomer/<int:id>',views.delCustomer,name="delCustomer"),
path('deletedCustomer/<int:id>',views.deletedCustomer,name="deletedCustomer"),
]
Code for setting up the modules used for frontend:

class Game(models.Model):
game_id = models.IntegerField(primary_key=True)
game_name = models.CharField(max_length=100)
game_type = models.CharField(max_length=100)
age_rest = models.IntegerField()
height_rest = models.IntegerField()
rate = models.IntegerField()
duration = models.IntegerField()

class Meta:
managed = False
db_table = 'game'

class Customer(models.Model):
customer_id = models.IntegerField(primary_key=True)
customer_name = models.CharField(max_length=100)
debitcard_id = models.IntegerField()
age = models.IntegerField()
height = models.IntegerField()
house_no = models.IntegerField()
street_no = models.IntegerField()
pin_code = models.IntegerField()

class Meta:
managed = False
db_table = 'customer'

Code for fetching, editing, deleting and sorting in the database:

from django.shortcuts import render


from GameZoneApp.models import Game,Customer
from django.contrib import messages
from django.http import HttpResponse
from GameZoneApp.forms import
GameForms,CustomerForms from django.db import connection

def HomePage(request):
return render(request,'HomePage.html')
def showGame(request):
showall=Game.objects.all()
context = {
'data': showall
}
return render(request,'showGame.html',context)

def sortGame(request):
if request.method=="POST":
if request.POST.get('Sort'):
type=request.POST.get('Sort')
sorted=Game.objects.all().order_by(type)
context = {
'data': sorted
}
return render(request,'sortGame.html',context)
else:
return render(request,'sortGame.html')

def insertGame(request):
if request.method=="POST":
if request.POST.get('game_id') and request.POST.get('game_name') and
request.POST.get('game_type') and request.POST.get('age_rest') and request.POST.get('height_rest') and
request.POST.get('rate') and request.POST.get('duration'):
saverecord=Game()
saverecord.game_id=request.POST.get('game_id')
saverecord.game_name=request.POST.get('game_name')
saverecord.game_type=request.POST.get('game_type')
saverecord.age_rest=request.POST.get('age_rest')
saverecord.height_rest=request.POST.get('height_rest')
saverecord.rate=request.POST.get('rate')
saverecord.duration=request.POST.get('duration')

allval=Game.objects.all()

for i in allval:
if int(i.game_id)==int(request.POST.get('game_id')):
messages.warning(request,'Game already exists....!');
return render(request,'insertGame.html')

saverecord.save()
messages.success(request,'Customer '+saverecord.customer_name+' is saved succesfully!!')
return render(request,'insertCustomer.html')
saverecord.save()
messages.success(request,'Game '+saverecord.game_name+' is saved succesfully!!')
return render(request,'insertGame.html')
else:
return render(request,'insertGame.html')

def editGame(request,id):
editGameObj=Game.objects.get(game_id=id)
context={
"Game":editGameObj
}
return render(request,'editGame.html',context)

def updateGame(request,id):
updateGame=Game.objects.get(game_id=id)
form=GameForms(request.POST,instance=updateGame)
if form.is_valid():
form.save()
messages.success(request,'Record updates succesfully!!')
return render(request,'editGame.html',{"Game":updateGame})

def delGame(request,id):
delGameObj=Game.objects.get(game_id=id)
context={
"Game":delGameObj
}
return render(request,'delGame.html',context)

def deletedGame(request,id):
delGameObj=Game.objects.get(game_id=id)
delGameObj.delete()
showall=Game.objects.all()
messages.success(request,'Record deleted succesfully!!')
return render(request,'delGame.html',{"Game": delGameObj})

def showCustomer(request):
showall=Customer.objects.all()
context = {
'data': showall
}
return render(request,'showCustomer.html',context)

def insertCustomer(request):
if request.method=="POST":
if request.POST.get('customer_id') and request.POST.get('customer_name') and
request.POST.get('debitcard_id') and request.POST.get('age') and request.POST.get('height') and
request.POST.get('house_no') and request.POST.get('street_no') and request.POST.get('pin_code'):
saverecord=Customer()
saverecord.customer_id=request.POST.get('customer_id')
saverecord.customer_name=request.POST.get('customer_name')
saverecord.debitcard_id=request.POST.get('debitcard_id')
saverecord.age=request.POST.get('age')
saverecord.height=request.POST.get('height')
saverecord.house_no=request.POST.get('house_no')
saverecord.street_no=request.POST.get('street_no')
saverecord.pin_code=request.POST.get('pin_code')

allval=Customer.objects.all()

for i in allval:
if int(i.customer_id)==int(request.POST.get('customer_id')):
messages.warning(request,'Customer already exists....!');
return render(request,'insertCustomer.html')

saverecord.save()
messages.success(request,'Customer '+saverecord.customer_name+' is saved succesfully!!')
return render(request,'insertCustomer.html')
else:
return render(request,'insertCustomer.html')

def sortCustomer(request):
if request.method=="POST":
if request.POST.get('Sort'):
type=request.POST.get('Sort')
sorted=Customer.objects.all().order_by(type)
context = {
'data': sorted
}
return render(request,'sortCustomer.html',context)
else:
return render(request,'sortCustomer.html')

def editCustomer(request,id):
editCustomerObj=Customer.objects.get(customer_id=id)
context={
"Customer":editCustomerObj
}
return render(request,'editCustomer.html',context)

def updateCustomer(request,id):
updateCustomer=Customer.objects.get(customer_id=id)
form=CustomerForms(request.POST,instance=updateCustomer)
if form.is_valid():
form.save()
messages.success(request,'Record updates succesfully!!')
return render(request,'editCustomer.html',{"Customer":updateCustomer})

def delCustomer(request,id):
delCusObj=Customer.objects.get(customer_id=id)
context={
"Customer":delCusObj
}
return render(request,'delCustomer.html',context)

def deletedCustomer(request,id):
delCusObj=Customer.objects.get(customer_id=id)
delCusObj.delete()
showall=Customer.objects.all()
messages.success(request,'Record deleted succesfully!!')
return render(request,'delCustomer.html',{"Customer": delCusObj})

def runQueryGame(request):
raw_query = "select * from gamezone.game;"

cursor = connection.cursor()
cursor.execute(raw_query)
alldata=cursor.fetchall()

return render(request,'runQueryGame.html',{'data':alldata})
def runQueryCustomer(request):
raw_query = "select customer_id, customer_name, customer.debitcard_id, balance from
gamezone.customer join gamezone.debitcard on customer.debitcard_id=debitcard.debitcard_id;"

cursor = connection.cursor()
cursor.execute(raw_query)
alldata=cursor.fetchall()

return render(request,'runQueryCustomer.html',{'data':alldata})

2. Screenshots of the Website that connects the Database:

1. Home Page
2. Customer Database

3. Sorting Customer Records


4. Insert a Customer Record

5. Edit Game Record


6. Delete Game Record

7. Query1: Display all the details of games of type “Racing” and age restriction>=18.
8. Query 2: Display Customer ID, Customer name, their Debit Card ID and
account balance.

Github Repository Link: https://github.com/yash-sakaria-1611/Game-Zone-Web-App

You might also like