mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Created a markdown file with the base tables for genre substituion, as well as how to store them and work with them
This commit is contained in:
parent
519da8b940
commit
50046d79bd
71
Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md
Normal file
71
Phase2/Godot_Toolset/Documentation/GenreDatabaseSchemas.md
Normal file
@ -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';
|
||||
```
|
Loading…
Reference in New Issue
Block a user