K
K
Kolya Vantukh2020-01-25 18:19:54
MySQL
Kolya Vantukh, 2020-01-25 18:19:54

Have I designed the tables in the database correctly?

Briefly about the essence: there is such a concept in the domain logic as the arrival of money. The arrival can be of different types. Depending on the type, you need to specify additional. fields when adding an arrival and save them. I decided to create a separate table in the database for each type and connect it to the main income table through a 1:1 relationship.
This is how my tables look like
a table of receipts money_comingwith fields

-id
-amount
-type_id
-date_added

table for a specific type of receipt (in this case, receipt from the client) client_moneycoming with fields
-id
-money_coming_id
-client_id
-order_code

I wanted to ask if I did the right thing or is there a better way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mayton2019, 2020-01-25
@vkolya

In practice, no one creates tables with 1:1 relationships. There are, of course, exceptional cases. They are related to bypassing the restrictions on the use of BLOB fields and other things, but this is definitely not your case.
You can safely combine two plates into one and everything will be fine. If you didn't make a mistake with the normalization.

A
Andrey, 2020-01-25
@VladimirAndreev

Will there be filtering by additional fields?
If not, and the database supports json fields, I would use them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question