- Define MySQL schema in the CS3 server
- Define tables for generators and events meta data
- Define the table for users
- Single sql file called
game.sql
In this lab, your job is to create the necessary schema designs for the meta data including generators and events. In other word, by the end of this lab, you should have the generators and events meta data information schema ready in CS3 MySQL Server.
In additional to the game meta data, you will also need to define the users table to store who is authorized to login. From the users table, you need to add up the creator information to the generators and events meta data table.
Before we start diving into the detail, I've created an application for you to test your SQL logic here: http://104.131.155.18:8000/91961f18b3ec7bcff0fa2142f65fa17e
Please use the SQL unit test website to confirm your result. In specific, I should be able to copy your submission and paste in the SQL unit test website and see them all passing (or failing).
In specific, you will need to create the query for the following items:
- Create
users
table- Use
DESCRIBE users;
to test your result after creating the table
- Use
- Create
generators
tablecreated_by
should be reference key tousers
table
- Use
DESCRIBE generators;
to test your result after creating the table
- Create
events
tablecreated_by
should be reference key tousers
table
- Use
DESCRIBE events;
to test your result after creating the table
- Create
quantities
table- Combination of
token
andgenerator_id
should be unique
- Use
DESCRIBE quantities;
to test your result after creating the table
- Combination of
- Insert sample records to
users
like below- After insert, use
SELECT * FROM users;
to test the result
- After insert, use
- Insert sample records to
generators
like below- After insert, use
SELECT * FROM generators;
to test the result
- After insert, use
- Insert sample records to
events
like below- After insert, use
SELECT * FROM events;
to test the result
- After insert, use
- Insert sample records to
quantities
like below- After insert, use
SELECT * FROM quantities;
to test the result
- After insert, use
- Update generator record of name "grandma" to have
unlock_at
value of 10 andrate
of 1- After update, use
SELECT * FROM generators;
to test the result
- After update, use
- Find out the information of generators including quantity, name, description, rate, base_cost and unlock_at for token
80516ce4663c3bd0c8385309a2fe226e
- Find out which generator has the most
unlock_at
value - Find out all the generators with the order of
unlock_at
from lowest to highest - Delete an event called "sample event"
- After delete, use
SELECT * FROM events;
to test the result
- After delete, use
id | username | password |
---|---|---|
1 | admin | cs3220password |
2 | me | notapassword |
id | name | description | rate | base_cost | unlock_at | created_by |
---|---|---|---|---|---|---|
1 | Grandma | Grandma likes to make cookies | 5 | 10 | 10 | 1 |
2 | Factory | Factory to produce cookies | 10 | 50 | 50 | 1 |
3 | Mine | Mining cookies | 20 | 200 | 200 | 2 |
id | name | description | trigger_at | created_by |
---|---|---|---|---|
1 | Grandma shows up | You always know grandma likes to make cookies | 10 | 1 |
2 | You can construct factory now! | Factory to produce cookies | 50 | 1 |
3 | We've found cookies in deep mountain ... in the mine? | Mining cookies | 200 | 2 |
4 | sample event | This is a sample event. Please delete me | 99999 | 2 |
generator_id | token | quantity |
---|---|---|
1 | c7a69d44e0b9b415b2d9956cb26b944a | 2 |
2 | c7a69d44e0b9b415b2d9956cb26b944a | 1 |
1 | 80516ce4663c3bd0c8385309a2fe226e | 20 |
2 | 80516ce4663c3bd0c8385309a2fe226e | 30 |
- None
- Pass sql-unit-test test cases