From 50046d79bd695cd9c4039b0f2a0a648b28cf48bd Mon Sep 17 00:00:00 2001 From: PersonGuyGit Date: Sun, 8 Oct 2023 12:57:32 -0600 Subject: [PATCH] Created a markdown file with the base tables for genre substituion, as well as how to store them and work with them --- .../Documentation/GenreDatabaseSchemas.md | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md diff --git a/Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md b/Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md new file mode 100644 index 0000000..d10b2c2 --- /dev/null +++ b/Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md @@ -0,0 +1,71 @@ +1. **Table: Items** + - This table will store information about base items like powerups. + + ```sql + CREATE TABLE items ( + item_id serial PRIMARY KEY, + name VARCHAR(255) NOT NULL + ); + ``` + +2. **Table: Synonyms** + - This table will store synonyms for each item, referencing the `items` table. + + ```sql + CREATE TABLE synonyms ( + synonym_id serial PRIMARY KEY, + item_id INT REFERENCES items(item_id), + synonym VARCHAR(255) NOT NULL + ); + ``` + +3. **Table: Genres** + - This table will store different genres, like "fantasy" or "modern day." + + ```sql + CREATE TABLE genres ( + genre_id serial PRIMARY KEY, + name VARCHAR(255) NOT NULL + ); + ``` + +4. **Table: Items_Genres** + - This table will establish a many-to-many relationship between items and genres, as an item can belong to multiple genres. + + ```sql + CREATE TABLE items_genres ( + item_id INT REFERENCES items(item_id), + genre_id INT REFERENCES genres(genre_id), + PRIMARY KEY (item_id, genre_id) + ); + ``` + +With this schema, you can: + +- Add base items like powerups to the `items` table. +- Associate synonyms for each base item in the `synonyms` table, referencing the corresponding item. +- Categorize base items into different genres in the `genres` table. +- Establish relationships between base items and genres in the `items_genres` table. + +Here's an example of how you might use this schema: + +```sql +-- Insert a base item +INSERT INTO items (name) VALUES ('Health Potion'); +-- Insert synonyms for the base item +INSERT INTO synonyms (item_id, synonym) VALUES (1, 'Health Potion'); +INSERT INTO synonyms (item_id, synonym) VALUES (1, 'Stimpack'); +-- Insert genres +INSERT INTO genres (name) VALUES ('Fantasy'); +INSERT INTO genres (name) VALUES ('Modern Day'); +-- Associate the base item with genres +INSERT INTO items_genres (item_id, genre_id) VALUES (1, 1); -- Health Potion belongs to Fantasy +INSERT INTO items_genres (item_id, genre_id) VALUES (1, 2); -- Health Potion also belongs to Modern Day +-- Select the Fantasy name of an the heavy armor base item that you are looking for. +SELECT genres.name +FROM genres +JOIN items_genres ON genres.genre_id = items_genres.genre_id +JOIN base_items ON items_genres.base_item_id = base_items.item_id +WHERE base_items.name = 'heavy armor' + AND genres.name = 'Fantasy'; +```