How should I implement items that are normalized in the Database, in Object Oriented Design?
- by Jonas
How should I implement items that are normalized in the Database, in Object Oriented classes?
In the database I have a big table of items and a smaller of groups. Each item belong to one group.
This is how my database design look like:
+----------------------------------------+
| Inventory |
+----+------+-------+----------+---------+
| Id | Name | Price | Quantity | GroupId |
+----+------+-------+----------+---------+
| 43 | Box | 34.00 | 456 | 4 |
| 56 | Ball | 56.50 | 3 | 6 |
| 66 | Tin | 23.00 | 14 | 4 |
+----+------+-------+----------+---------+
Totally 3000 lines
+----------------------+
| Groups |
+---------+------+-----+
| GroupId | Name | VAT |
+---------+------+-----+
| 4 | Mini | 0.2 |
| 6 | Big | 0.3 |
+---------+------+-----+
Totally 10 lines
I will use the OOP classes in a GUI, where the user can edit Items and Groups in the inventory. It should also be easy to do calculations with a bunch of items. The group information like VAT are needed for the calculations.
I will write an Item class, but do I need a Group class? and if I need it, should I keep them in a global location or how do I access it when I need it for Item-calculations? Is there any design pattern for this case?