0

I have multiple properties that are joined with the items table

all of them can be stored as a string, should I have multiple tables for different properties like:

colors table, images table, etc.

or should I make them in one table

colors and images table

and store all of the data in this table

I want to make a good database design, I tried to store all the data in one table but when I search these tables I get mixed data, that need to be filtered.

Is making different tables a good practice?

Alsaraha
  • 1
  • 2

1 Answers1

2

Generally, separate tables for each object type is a sensible design that will serve you well later on.

You haven't provided a ton of details about these other objects Colors and Images but they are technically different objects and probably should be in separate tables then. E.g. ItemColors and ItemImages, if they're only specific to Items.

The only exception I'd say to the above is if all of the following is true:

  1. They are single property objects (e.g. properties themselves) with no chance of additional properties about them being added later on.
  2. They only relate specifically to Items.
  3. They always have a 1-to-1 relationship with the Items (meaning one Item can only have one Color and one Image).

Then for simple designs for simple applications, they theoretically can live as columns directly in the Items table itself.

J.D.
  • 37,483
  • 8
  • 54
  • 121