Architeture

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm developing my first real object-oriented project, and having some
trouble...

Simple scenario:

DB
Table Orders, Fields: Client, Date
Table OrderDetails, Fields: OrderID, Product, Price, Quantity, Discount

Businness Entity
Order, Fields: Client, Date, TotalQuantity, TotalPrice

How should I fill TotalQuantity and TotalPrice fields???
The first approach is using a view, but I don't want to have businness
logic in the database, nor use aggregate functions.
The second, would be creating those fields in the Orders table, but that
would be a waste of space and code.
The third, would be filling the businness entities in the code itself, but
for that, I would need to load all order details in the memory, and loop for
each one. This is ok when I already need all order details, but in a simple
view of all orders, it's not that good.

I still think the third option is the best. Maybe you can give me a clue.

Thanks,
Bruno Rodrigues.
 
Why don't you want to use aggregate functions? They'd be far faster and more
effiicient than anything you could code.
 
Bruno said:
Hi,

I'm developing my first real object-oriented project, and having some
trouble...

Simple scenario:

DB
Table Orders, Fields: Client, Date
Table OrderDetails, Fields: OrderID, Product, Price, Quantity, Discount

Businness Entity
Order, Fields: Client, Date, TotalQuantity, TotalPrice

How should I fill TotalQuantity and TotalPrice fields???
The first approach is using a view, but I don't want to have businness
logic in the database, nor use aggregate functions.
The second, would be creating those fields in the Orders table, but that
would be a waste of space and code.
The third, would be filling the businness entities in the code itself, but
for that, I would need to load all order details in the memory, and loop for
each one. This is ok when I already need all order details, but in a simple
view of all orders, it's not that good.

I still think the third option is the best. Maybe you can give me a
clue.

The first. Your database must contain part of Business Logic, whether
you like or not.
 
Back
Top