Heya, Denisa.
It always starts out so easy. But nobody wants to live in a tiny house, and contractors are SO expensive....
There are several ways you could combine your tables, some more normalized than others.
Ideally, you'd want to split up your data into a few tables:
- An `expenses` table, with a numeric primary key, and amount and a date.
- An `expenses_attributes` table with a field name and field value, as well as a reference to the primary key from `expenses`
- You might also want an `expenses_categories` and `expenses_categories_map` table so that you can keep categorical data separate from 'memo' fields.
An an example, for gasoline, you might have an entry in `expenses`:
[id:102, date:2007-09-11 20:56:45, amount:45.00]
Then in the `expenses_attributes` table:
[id:102, field:quantity, value:12.85]
Then in `expenses_categories_map`:
[id:102, category:5]
And finally in `expenses_categories`:
[id:5, name:gasoline]
It would take some neat-looking joins to view all your data at once (or you could create some
views), but then you could more reliably customize and summarize your data without worrying about data duplication or empty space.
If you wanted to get REALLY exciting (and *fun* to maintain), add a `vendors` table and add a reference to the vendor ID in your `expenses` table:
[id:102, date:2007-09-11 20:56:45, amount:45.00, vendor:86]
And in `vendors`:
[id:86, name:QuikTrip]
[EDIT: And don't forget about split transactions! How's that house coming? :) ]