I am building a small system to control my rental properties. In this system, I want to be able to capture any regulations that can happen to a lease. A regulation can happen for:
- The rent amount
- The prepaid rent amount
- The prepaid deposit amount
I am thinking on how I can structure this. I have a Lease model with leases table (simplified):
id | name | address | rent | prepaid_rent_amount | prepaid_deposit_amount
1 | Unit no. 1 | Highland Drive | 1000 | 3000 | 3000
In order to capture if any regulation has happened on the above three parameters (rent amount, prepaid rent or prepaid deposit), I need to store this in a database. The information needed to be capture from these parameters are almost identical:
//Regulation in rent
- lease_id
- amount
- date
- flag
//Regulation in prepaid rent
- lease_id
- amount
- date
//Regulation in prepaid deposit
- lease_id
- amount
- date
Solution 1
I was thinking to create a model/table for each parameter, and simply just store data relevant for each regulation in the corresponding table:
RentRegulationPrepaidRentRegulationPrepaidDepositRegulation
I think the benefits of this solution is that the data is separated, however it feels like it is bloating my codebase.
Solution 2
Instead of creating three models/tables to store the above information in, I was thinking to just create one model:
Regulation
An inside this model, simply have a column called type. The value for this column would then control what kind of regulation we were talking about (e.g. RentRegulation, PrepaidRentRegulation etc.)
The only concern I have for solution #2, is for the type RentRegulation there can be different types of regulations. So a rent can be regulated due to the following stuff (all regulated by law):
- Increase in inflation
- Renovating the lease
- Agreement with the tenant that rent should increase
To cater for the above, I was thinking of also adding a nullable flag column to the regulations table, and then just rely on scopes when retreiving data?