I need to make a library system for book loans, in which I wrote this database diagram. the teacher said that this diagram is inconsistent. What needs to be done, are these tables just what I really need?
I need to make a library system for book loans, in which I wrote this database diagram. the teacher said that this diagram is inconsistent. What needs to be done, are these tables just what I really need?
When modeling tables in a relational database you should start by trying not to repeat the information in different tables by making use of the relationships.
For example, there is a t_alunos_has_t_emprestimos
table that seems to be used to relate loans to students and at the same time to books. But the student information already appears to exist in the t_emprestimos
table.
I would advise the following process:
Alunos
, Emprestimos
and Livros
. However depending on the requirements you may decide to add more entities. For example, imagine the case where a Student has more than one contact. It may make sense to add a Contacto
entity. It's your decision. nome
for entity Aluno
. Or titulo
, ano
, isbn
for entity Livros
. Emprestimo
is related only to Aluno
, it is a "one to many" relationship. You should put a aluno
field in the Emprestimo
table. Emprestimo
can contain several Livros
. It's a "many-to-many" relationship. This type of relationship requires a new table. You should define a (pivot) table that contains the relationship between Emprestimo
and Livro
. Read more about database normalization. You can find some information about the "Normal Forms" here or, if you feel comfortable with the English, here . Try to follow the Third Normal Form.
It's hard to help otherwise, because everything depends on your requirements.