Re: OO DB question
- From: "Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx>
- Date: Sun, 25 Dec 2005 19:15:41 -0000
"Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx> a écrit dans le message de
news: OmX7YQYCGHA.532@xxxxxxxxxxxxxxxxxxxxxxx
And I still didn't really answer your question.
There really isn't anything that allows you to retrieve objects directly
froma database, which is why I mentioned the OPF idea. A database is not
modelled on tha same paradigm as an object model; the database uses a
relational model which is subtly different from an object model.
e.g.
database :
OrderLine
- ID: integer
- OrderID: integer
- Quantity: integer
- ProductID: integer
- UnitPrice: float
- Total: float
Order
- ID: integer
- Ref: string
- Date: DateTime
- CustomerID: integer
- Total: float
object model :
OrderLine
- ID: integer
- Quantity: integer
- Product: Product
- UnitPrice: float
- Total: float
Order
- ID: integer
- Ref: string
- Date: DateTime
- Customer: Customer
- Lines: List<OrderLine>
- Total: float
Notice that in the relational model, the Order table has no knowledge of the
OrderLine table but the OrderLine table has to have a foreign key field to
link its records to a particular record in the Order Table; there may be
additional referential integrity constraints and things like cascade
deletion to ensure that when an Order is deleted, all its Lines are also
deleted.
Using an OO approach, we can dispense with the foreign key from the Line to
the Order as the Order already knows about its Lines; in fact, there really
is no need for the Line to know about the Order, as in the relational model.
Notice also that we do not use integer IDs to link object together, but
instead real references to real objects.
It is this "impedance mismatch" between the relational model and the object
model that is resolved in an OPF. A mapping hierarchy lets us specify the
relational foreign key field links without polluting the object model. In
fact all a relational database behind an OPF has to do is simple single
table selects, updates and deletes, most of the time, as all the integrity
between objects is taken care of in the business object layer.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
.
- Follow-Ups:
- Re: OO DB question
- From: Chris
- Re: OO DB question
- References:
- OO DB question
- From: Chris
- Re: OO DB question
- From: Chris
- Re: OO DB question
- From: Joanna Carter [TeamB]
- OO DB question
- Prev by Date: null, list and generics
- Next by Date: Re: Typed List
- Previous by thread: Re: OO DB question
- Next by thread: Re: OO DB question
- Index(es):
Relevant Pages
|