dbTalk Databases Forums  

Re: Design question - when to generalize/specialize?

comp.databases comp.databases


Discuss Re: Design question - when to generalize/specialize? in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Hairgrove
 
Posts: n/a

Default Re: Design question - when to generalize/specialize? - 08-06-2003 , 03:41 PM






On 5 Aug 2003 11:17:27 -0700, velmurugan_p (AT) yahoo (DOT) com (Velmurugan
Periasamy) wrote:

Quote:
We are designing the object model for a new system. But we have a
legacy data model which stores both orders and order items in the same
table. The relationship (between order and order items) is maintained
through a self foreign key to the same table. We are discussing
possible alternatives to this model.

The developers of the old system say that the problem with storing
both orders and order items is the complexity of the SQL code (with
self-joins) and maintenance over time.

To the legacy model's defense, order and order items do have some
common attributes and similar life-cycles (like an order item could be
tracked in its separate workflow [as an order would be tracked]).

I agree it would be cleaner to separate the order item into its own
table. But I would like to find about general perspective, suggestions
on this issue. Which is better? What are the issues to be considered
from the perspective of designing the object model? From the
performance perspective?
An order item is not an order, although an order might contain only
one order item (it needs at least one, though). They are not the same
entity, therefore they belong in separate tables.

If you need to count orders grouped by customer, for example, it is
much faster to use the smaller orders table than to group over all the
rows representing order items as well as orders. Besides, you might
need to use a criteria such as "WHERE price IS NULL" in order to
filter out the line items, making efficient use of an index
impossible.

Although designing a proper billing and inventory system is far from
trivial, I think separating orders from order items brings many more
advantages than disadvantages, even with legacy DBMS which don't have
the latest relational features.


--
Bob Hairgrove
rhairgroveNoSpam (AT) Pleasebigfoot (DOT) com


Reply With Quote
  #2  
Old   
Velmurugan Periasamy
 
Posts: n/a

Default Re: Design question - when to generalize/specialize? - 08-07-2003 , 11:34 AM






Thanks for your input. It was helpful.

rhairgroveREMOVE (AT) THISbigfoot (DOT) com (Bob Hairgrove) wrote
Quote:
An order item is not an order, although an order might contain only
one order item (it needs at least one, though). They are not the same
entity, therefore they belong in separate tables.

If you need to count orders grouped by customer, for example, it is
much faster to use the smaller orders table than to group over all the
rows representing order items as well as orders. Besides, you might
need to use a criteria such as "WHERE price IS NULL" in order to
filter out the line items, making efficient use of an index
impossible.

Although designing a proper billing and inventory system is far from
trivial, I think separating orders from order items brings many more
advantages than disadvantages, even with legacy DBMS which don't have
the latest relational features.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.