Is this database structure designed efficiently?


I need to setup a DB where users can create categories within categories and inside the categories are multiple objects with multiple different stats

hierarchy example:

Cartoon > category
Simpsons > category (within the cartoon category)
Homer > object
Homer object stats > stupidity: 117
Homer object stats > color: yellow

I cant just make a table like:

-----------------------------
|character| Stupidy | color | 
-----------------------------
|Homer    | 111     |yellow |

because i need the users to be able to take away and add different object stats on their own (like add a stat of weight and remove color stats) for each object the stat types will be different plus with thousands of categories i don't want thousands of tables being generated by the users for the different objects.

My DB setup is in the google spreadsheet below which I feel works but I'm not the best with DB setups so I'm checking if there are some improvements.

I need to be able to display tables from the data displaying all item values that have a relationships with certain categories and/ or objects e.g. all simpsons characters weights or just homers weight.

https://docs.google.com/spreadsheets/d/1fHrugYv6JA3id_5zDxWaE-5IUNNGFo5yA1DZ1xQlqtg/edit?usp=sharing

Answer

Here is your database design:

enter image description here

Explanation:

  1. There may be many categories and each category may have many sub categories
  2. Each sub category may have many objects and
  3. Each object may have many keys and values

Cheers!!

source: stackoverflow.com
js interview questions