Database Reference
In-Depth Information
that can insert or update and that are aware that the customer entity is
stored in more than one table.
SQL Server, especially SQL Server 2008, offers us functionality to sim-
plify the logic in these procedures. We look at this functionality in detail in
the section “Implementing an Abstraction Layer.” For now, the most im-
portant thing to keep in mind is that your abstraction layer should abstract
the complexity of the underlying tables, and this usually means that it con-
tains structures that are more closely tied to entities.
An Abstraction Layer's Relationship
to Object-Oriented Programming
As you can guess by the name, object-oriented programming is a kind
of programming that uses objects. Objects are representations of real-
world items, and in that way they are similar to our concept of entities.
When programming an order management system, you will likely have ob-
jects that represent orders, order items, and customers. The objects have
properties, which are similar to attributes. Finally, objects also have
methods, or actions that the objects can perform. This is a very basic look
at objects—we could go on forever about the details—but the goal here is
to show the relationship between abstraction layers and object-oriented
programming.
Because objects closely resemble entities, the ties are there in plain
sight, as is the relationship between object properties and entity attributes.
Table 11.1 shows the properties of an Order object as it might exist in an
object-oriented programming language, and the corresponding attributes
that exist in our Order entity.
Right away you can see the clear relationship between an object and an
entity, but what about an object's methods?
Methods are actions that an object can perform. An Order object
might have methods to save the order, ship the order, cancel the order, add
a line item to the order, and so on, and some of these methods have direct
ties back to the database. For example, the method Order.Save may need
to insert the order and its related data into our SQL Server database.
These methods can be calls to a data layer, or a middle tier, but ultimately
a call to a stored procedure in SQL Server will probably be made. This can
 
 
Search WWH ::




Custom Search