From 45b0fe42a979d444d547a5248eb2e9e915aaf16a Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 14 Jan 2007 02:10:24 +0000 Subject: Add "block-content" to allow user comments on block level elements in quickstart docs. --- .../protected/pages/Database/ActiveRecord.page | 139 +++++++++++---------- demos/quickstart/protected/pages/Database/DAO.page | 70 +++++------ .../protected/pages/Database/SqlMap.page | 84 ++++++------- 3 files changed, 147 insertions(+), 146 deletions(-) (limited to 'demos/quickstart/protected/pages/Database') diff --git a/demos/quickstart/protected/pages/Database/ActiveRecord.page b/demos/quickstart/protected/pages/Database/ActiveRecord.page index 4dd70608..bc1d2359 100644 --- a/demos/quickstart/protected/pages/Database/ActiveRecord.page +++ b/demos/quickstart/protected/pages/Database/ActiveRecord.page @@ -1,7 +1,7 @@ -

Active Record

-

Active Records are objects that wrap a row in a database table or view, +

Active Record

+

Active Records are objects that wrap a row in a database table or view, encapsulates the database access and adds domain logic on that data. The basics of an Active Record is a business object class, e.g., a Products class, that match very closely the record structure @@ -13,21 +13,21 @@ Each field in the class must correspond to one column in the table. -

When to Use It

-

Active Record is a good choice for domain logic that isn't too complex, +

When to Use It

+

Active Record is a good choice for domain logic that isn't too complex, such as creates, reads, updates, and deletes. Derivations and validations based on a single record work well in this structure. Active Record has the primary advantage of simplicity. It's easy to build Active Records, and they are easy to understand.

-

However, as your business logic grows in complexity, you'll soon want +

However, as your business logic grows in complexity, you'll soon want to use your object's direct relationships, collections, inheritance, and so forth. These don't map easily onto Active Record, and adding them piecemeal gets very messy. Another argument against Active Record is the fact that it couples the object design to the database design. This makes it more difficult to refactor as a project goes forward.

-

The alternative is to use a Data Mapper that separates the roles of the +

The alternative is to use a Data Mapper that separates the roles of the business object and how these objects are stored. Prado provides a complimentary choice between Active Record and SqlMap Data Mapper. @@ -39,26 +39,28 @@ alt="Active Records and SqlMap DataMapper" id="fig:diagram.png" class="figure"/>

-

+

The Active Record class has methods that do the following: -