Specialization and generalization in database and application development

2

I have a Livros table and I know that book specialization / generalization is Livros de Ficção , Livros de Drama and Livros de Suspense , for example.

However, in the logical model, I do not know if I create a table Livros with relationship 1: N Tipos de livros with each type registered or a table is created for each specialization ( livro_drama , livro_ficção )!

I know it would be impractical to create a table for every Tipo , because if I needed new types of books I would have to always create a new table. But if I use the other form, each type of book entered would have its specific business rules, even registering each type, I would have to program the associated rules.

Something is bothering me in both solutions! How do I resolve this deadlock?

    
asked by anonymous 08.07.2018 / 22:28

2 answers

2

Is there any reason to have a specialization? If so, do you have any reason to have a generalization? It may seem obvious, but perhaps one of the two seems to be wrong in relational modeling. If you are speaking in specialization you do not have to talk about relationships, they are exclusionary concepts.

Do nothing for no reason. Ask yourself the reason to use something? What problem is this solving? And what are they being caused?

You say that each type of book has specific business rules. Really? are you sure? Let's say yes, and why are business rules in the database? Let's say you want to do so, what the question already shows that this is not a good idea, what solution do you see other than separating each type into a table? If the data behaves differently it must be in a different table. I just would not do so, within my vision, I might even need something out of the ordinary.

One solution is to have a table only and some actions that depend on the type are made conditionally.

There is no deadlock. I do not see any specialization or relationship there, so there is no dichotomy. It only has different business rules that are programmed in the application. Or in the database if you prefer. But you do not have to create a new table if the structure is the same. Database is not application, although some think it is.

See advantages and disadvantages of per the business rule in the database .

    
08.07.2018 / 23:23
-4

I was thinking that your book specializations might be, for example:

  • Digital Books
  • Audiobooks
  • Printed books

in which the nature of the reading experience was different in each case. Hence a specialization would make sense.

    

09.07.2018 / 01:41