-2

my question is very similar to question ,But i don't want to use EAV design

Rigth now ,we have these products in our store

Harddisk ->size(GB) ,speed ,price

Shirt -> size(M-L-S) ,color ,price

Book -> nummber of page , writer , price

1→ Methods

To design database ,I am trying use Inheritance approach

Product (SN,Odrer ,price ,Date )

Sub table

→ Harddisk ->size(GB) ,speed

→Shirt -> size(M-L-S) ,color

→Book -> nummber of page , writer

Product and Sub table have one to one relationship

But If in future new product comes with different attribute , i will create new table .

,Is it correct approch or is there any better approch ?

2→ Methods

Should i use Entity–attribute–value model ?

->Even if i will use EAV design and still i have update code with new entity and attribute?

->Design complexity===high

->readablity===low

->query cost===high

Please help/suggest me make a better design ?

2

1 Answer 1

0

The decision about designing the databases must be made based on how you want to query your data.

If your are going to query ALL your products at once (all type of products) then I will suggest you to put all your products in a single table (2nd solution). If most of your queries must return information about products of a single type, the solution with one-one relations will be better.

But in general the NoSQL databases are the best choice when you have dynamically changing structure.

You can even try to have a single table with 2 parts

  1. The structure that is same for all type of products.
  2. Json column that will keep structure that can be different for each row of your table.

In some relational database management systems you can also create indexes on JSON columns (for example PostgreSQL), to have better performance when retrieve data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.