Professional Documents
Culture Documents
Team ID : S5 - T3
Project title : Game Zone DBMS
Mentor Name: Shreyas Sir
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.
● 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.
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.
From this article, we understood the DBMS concepts like E-R Model, Database designing etc.
b. Interview(s)
1. Interview Plan
Interviewee:
Interviewer:
1) Yash SakariaDesignation: Business Development Executive
Purpose of Interview:
Preliminary meeting to identify problems and requirements regarding security at the MGZ
Pvt Ltd site.
Agenda:
● Interview Summary
Interviewee:
Interviewer:
Purpose of 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
Interviewee:
Interviewer:
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.
Interviewee:
Interviewer:
Purpose of Interview:
To understand the creation and maintenance of the system at the MGZ Pvt
Ltd site.
● 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
Interviewee:
Interviewer:
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
Interviewee:
Interviewer:
Purpose of Interview:
3. Questionnaire(s)
4. How often do you need assistance from the employee in a game zone?
1 - Occasionally
5 - Frequently
The graph is evenly distributed in terms of game categories and hence the games should be
bought accordingly.
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
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.
● 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
To get background knowledge on the Background Few similar Projects and 1 day
Game Zone readings requirements of Game Zone
To get knowledge of the real world Observations Employees of the Game Zone 1 hour
Gaming Zone
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
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.
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.
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.
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.
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
● 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.
● 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
1 data document
2 game create
5 list work
6 management system be
12 user access
17 customer have
19 developers add
20 software remove
22 gamers short
23 account balance like
36 id log
40 age register
41 name request
43 game_history serves
45 debit_history creates
48 online_game_tournament runs
50 auto_assign_debit_card records
51 whenever Required_age
55 update_balance stored
56 auto_balance_deduction desired
58 auto_assign_prize_money Waiting
59 prize money
60 real-world
61 flow
62 separate view
63 game logs
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
1 data General
3 list General
8 user Duplicate
13 software Irrelevant
15 gamers Duplicates
27 id Attributes
31 age Attributes
32 name Attributes
34 game_history Attributes
36 debit_history Attributes
38 realtime_playing Attributes
39 auto_assign_debit_card Associations
40 whenever Vague
44 update_balance Associations
45 auto_balance_deduction Associations
46 account balance Attributes
47 auto_assign_prize_money Associations
49 real-world General
50 flow Vague
4. Rejected Verbs:
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. 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
● 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.
● 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.
● 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.
● 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)
1. DDL Scripts
2. Snapshots of Table
3. SQL Queries
1. DDL Scripts:
1. Debitcard
2. Customer
4. Contact No
5. Waits
6. Game History
7. Tournament
8. Registers
9. Takes
10. TransactionHistory
11. Owner
13. Manager
14. Employee
● Registers(CustomerID, TournamentID)
● Takes(GameID, TournamentID)
● 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 *
from gamezone.waits
where customer_id=5;
3. Display all the Game names and Game IDs with game type RPG
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 '_____';
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';
select mobile_no
from gamezone.contact_no
where customer_id=22;
9. Display the number of games played in the tournament with tournament id.
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;
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;
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;
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.
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;
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'OPTIONS': {
'options': '-c search_path=gamezone'
},
'NAME': 'gamezone',
'USER': 'postgres',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}
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'
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})
1. Home Page
2. Customer Database
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.