Architeture

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.
 
S

Sean Hederman

Why don't you want to use aggregate functions? They'd be far faster and more
effiicient than anything you could code.
 
A

Aquila Deus

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top