A
A
Alexander Fedorov2015-09-24 18:35:26
Yii
Alexander Fedorov, 2015-09-24 18:35:26

How to store and process similar entities (for example, planned and actual transactions)?

There are two entities: a planned and an actual transaction, they have all the main fields the same (date, amount, account, counterparty, tags), but a planned transaction may have additional parameters - regularity.
I see two implementation options:
1. General table of transactions + field indicating the type of transaction.
In this case, saving on models, controller, but from the minuses - you must always remember about the two entities with which you are working.
Planned transaction-specific fields - in a separate table with a one-to-one relationship.
2. Each entity has its own table + MVC
From the pros - you can customize each entity as you like
From the minuses - you will have to duplicate similar functionality.
I'm leaning towards the first option for now. Tell me, please, what is your experience?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2015-09-24
@Pagliaccio

Three tables and three models. One keeps all the communities. The two keep the differences. Never duplicate data in different tables in a database.
Or 1 table and 2 models.

M
matperez, 2015-09-24
@matperez

If the whole difference between transactions is that some of them can be repeated, then does the transaction itself need to know about this at all? I would just start a table with transactions and separately store information on their frequency somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question