Mysql. 1 table for all properties of all entities or 1 table for each entity


Currently, I am dealing with database structure and I would like to get a piece of advice.

I have 2 objects: banner and ad.

For them I may create banner table and ad table, which will hold all the info about each entity. As main advantage I see that everything related to 1 entity is in this entity table.

On the other hand, I may some table like: entity_properties. It will hold value_id entity_id property value. The main advantage is that for entities I need only some basic fields, other fields can be put in this table.

But I am not sure which is the better practice and performance? Thanks in advance.

For the sake of normalization it is always better to have 1 table per 1 entity. Normalization is an aim or an approach to minimize redundancy and dependency in relational databases . In your case banner and ad are different entities. For now it seems that you can use them in same table. So "redundancy" is not the case. However, what if you want to add some additional fields later?

In addition code complexity and readability is another issue. For instance, when you add different types of object in same table you need to add an internal logic to differentiate them in your code. This means you have complex and probably less readable code.