O
O
Oleg Pravdin2020-05-20 12:31:14
Database design
Oleg Pravdin, 2020-05-20 12:31:14

How to store categories of different entities in the database?

Good afternoon. I have the entities "device" and "spare part" in the database. It is not possible to combine them into one "object" (because they have different business logic). However, it is necessary to categorize both of these entities. What is the right thing to do: store catalog categories in one table (adding a column linking the entity and the category) or make 2 identical tables for 2 different entities?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kudrya, 2020-05-21
@Mugenzo

if an entity can have only 1 category, then you can store it in 1 table,
if there are several, then either make 2 tables or 1 intermediate one in which there will be 3 fields, category id, entity id and entity type (device or spare part)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question