-2

I am creating a web application where each user can create theire own categories. Currently i am thinking about creating category table for each user which contains only the catogories that specific user created. but i feels like this is bad approach.

For example if "Food" is a category created by User1 and User2 it will be repeated in 2 tables. also i don't want to create a static table with some categories since i want to allow the user to add their own catogries. what is the best approach to handle this?

Shadow
  • 33,525
  • 10
  • 51
  • 64
vishnu.k
  • 31
  • 4
  • [How can you represent inheritance in a database?](https://stackoverflow.com/q/3579079/3404097) [More](https://stackoverflow.com/q/190296/3404097) [How to design a product table for many kinds of product where each product has many parameters](https://stackoverflow.com/q/695752/3404097) [More](https://stackoverflow.com/a/2945124/3404097) [And more](https://stackoverflow.com/q/5106335/3404097) [Re EAV](https://stackoverflow.com/a/23950836/3404097) etc etc etc [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/3404097) – philipxy Oct 29 '22 at 14:39
  • A single table would work if you have `PRIMARY KEY(user_id, category)`. – Rick James Oct 31 '22 at 00:43

1 Answers1

-1

One thing you should never do is making tables for individual users, products, customers, companies or any other edge case. A data structure exists to structure data/quanta and that's it.

The best way to handle this is to let user 1 and user 2 create whatever category they like and eat whatever they want so you can focus on things and people that really matter, right?

Gerballi
  • 441
  • 5