How to implement objects that are normalized in a database in an object-oriented design?

How to implement objects normalized in the database in object-oriented classes?

In the database, I have a larger table of elements and fewer groups. Each element belongs to one group.

Here's what my database design looks 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 OOP classes in the GUI, where the user can edit items and groups in the inventory. It should also be easy to make calculations with a bunch of items. For calculations, these groups are required, such as VAT.

I will write an Item class, but do I need a Group class? and if I need it, should I store them in a global location or how do I access it when I need it for Item calculations? Is there a design template for this case?

+3
2

, ORM (- ). OO, , , .

, , Group, Item s ( ) Item Group. , ORM , ( ).

+2

, . , 1: Inventory, Group . .

+1

Source: https://habr.com/ru/post/1747538/


All Articles