Re: Help! Difficulty understanding DB -> Object mapping
- From: Mike Austin <no@xxxxxxxx>
- Date: Sun, 08 May 2005 19:29:09 GMT
frebe wrote:
I do need to record the title of the product with the line item, that seems for sure price too.
Denormalizing data might only be a good idea in datawarehouse solutions. In your transactional database, the schema must be normalized. The product title (and price) can be retrieved by a very simple join.
with data that may change copied into the LineItem.
If you need history in your database, you change the schema to this: OrderLineItem(Order_ID, Product_ID, ProductVersion,...) Product(Product_ID, ....) ProductVersion(ProductVersion, title, price, ....)
Copying all product data into every order line would cause you a data bloat.
I see your point here, but orders may be volatile - you may want to change a description or some other data per customer per order - maybe a customized version of a product. You don't want to add a new product for every small one-off change.
Also, if you basically move everything to ProductVersion, you might as well consolidate the versions into one table, no?
PRODUCT: Product_ID, Product_Version, Title, Price ORDER_ITEM: Order_ID, Product_ID, Product_Version
Mike
It seems that from the application, it is necessary to load the
Product
object from somewhere
From the database, direct (using ADO) or indirect.
This seems like too many queries...
What is the problem with this? Queries is a good way to fetch the data you want for the current context.
To view Order contents at the UI, have a different structure to bring back the necessary data to be viewed, be that a resultset or other information object?
Using resultsets is the simpliest solution, but it is not type-safe and error-prone (column names are types as strings). The domain object solution, will force you to write many find- and load-methods, unless you use a competent O/R mapper.
I am using .NET - could you recommend somehting?
No, I am using java. But I have heard that ADO is more capable than JDBC, so I would probably use ADO directly.
Fredrik Bertilsson http://butler.sourceforge.net
.
- Follow-Ups:
- References:
- Help! Difficulty understanding DB -> Object mapping
- From: usenet . news . account
- Re: Help! Difficulty understanding DB -> Object mapping
- From: frebe
- Re: Help! Difficulty understanding DB -> Object mapping
- From: usenet . news . account
- Re: Help! Difficulty understanding DB -> Object mapping
- From: frebe
- Help! Difficulty understanding DB -> Object mapping
- Prev by Date: Re: polymorphism and dynamically typed languages
- Next by Date: Re: Lahman, how ya doing?
- Previous by thread: Re: Help! Difficulty understanding DB -> Object mapping
- Next by thread: Re: Help! Difficulty understanding DB -> Object mapping
- Index(es):
Relevant Pages
|