Example of Tracing back to Requirements

The following is an example of a data modeling task in which all modeling decisions have been traced back to the requirements. It begins with the requirements document, then performs the data modeling task in a series of steps.

Requirements

The latest "hot" e-commerce company is Customized-Book.com. Their plan is to sell truly customized books to the general public. Customers who log onto the Customized-Book.com Web site can specify exactly what they want in their books. Customized-Book.com will then scan through their large collection of book components for exactly those components that satisfy the customer's specification. The book components are combined together with a table of contents, index and introduction. Each book is then printed, bound and shipped to the shipping address specified by the customer.

Each customer has a name, address, login name and password. The customer may fill their "shopping cart" with one or more customized books. A customized book has a specification, price and shipping address (including a name and address) if different from the customer's address.

Each customized book matches various book components. A book component has a content, price and author. Each author has a name that uniquely determines the author within this database. Book components also have specifications. Specifications are boolean expressions based on elementary specifications.

Find Candidates for Classes

Looking through the requirements we find the following nouns occurring repeatedly:

TermSynonym(s)Class
customized bookbookCustomizedBook
customerCustomer
addressAddress
shipping addressShippingAddress
book componentcomponentBookComponent
specificationcustomer's specification, expressionSpecification
operationboolean expressionOperation
shopping cartlog in (session)ShoppingCart
elementary specificationElementarySpecification
authorAuthor

Find relationships

One now looks for phrases that suggest relationships from one class to another. The first class in an association is called the "source" class, and the second is the "target". The inheritance or "isa" relationship is called "extends" below. For each relationship, I have noted the phrase in the original requirements that justifies the relationship. Citing another document to justify an element of a data model (or of another modeling or design task) is called tracing.

PhraseSourceRelationshipTarget
Customers who log onto the ... siteCustomerfillShoppingCart
Customers ... can specify exactly what they want in their books CustomizedBooksatisfiesSpecification
book components ... satisfy the customer's specification BookComponentsatisfiesSpecification
The book components are combined together... CustomizedBookcomposedOfBookComponent
Each book is ... shipped to the shipping address CustomizedBookshippedToShippingAddress
Each customer has an ... address ... CustomerlivesAtAddress
The customer may fill their "shopping cart" with one or more customized books ShoppingCartcomposedOfCustomizedBook
A customized book has a specification... CustomizedBooksatisfiesSpecification
A customized book has a ... shipping address CustomizedBookshippedToShippingAddress
shipping address (including a name and address) ShippingAddressextendsAddress
Each customized book matches various book components CustomizedBookcomposedOfBookComponent
A book component has an ... author BookComponentwrittenByAuthor
Book components also have specifications BookComponentsatisfiesSpecification
...boolean expressions based on elementary specifications ElementarySpecificationextendsExpression
...boolean expressions... OperationextendsExpression
...boolean expressions... OperationoperatesOnExpression

Find attributes

Words that modify nouns are used to determine the attributes that each class should have. As with the relationships, each attribute is traced back to the requirements.

PhraseClassAttribute
The book components are combined together with a table of contents, index and introductionCustomizedBooktableOfContents
index
introduction
Each customer has a name, ..., login name and password Customername
loginName
password
A customized book has a ..., price and ... CustomizedBookprice
shipping address (including a name and address)ShippingAddressname
A book component has a content, price and ... BookComponentcontent
price
Each author has a name that uniquely determines the author Authorname

Find operations

Verbs that imply an action rather than just a relationship (as well as verbs that suggest both an action and a relationship) should be represented as operations. Operations were also traced back to the requirements.

PhraseClassOperation
Customers who log onto the ... siteCustomerlogin
The book components are combined ...CustomizedBookcombineComponents
Each book is then printed, bound and shipped ... CustomizedBookprint
bind
ship
The customer may fill their "shopping cart" ... CustomeraddNewCustomizedBook
removeCustomizedBook
Each customized book matches various book components Specificationmatches

Draw Class Diagram

The class diagram is now drawn so that it has the classes and associations required above.

One must also choose cardinality constraints. For example, the "0..1" constraint on the shippedTo association is the result of the phrase "if different from the customer's address." in the requirements. Here is the diagram without attributes. The cardinality constraints should also be traced back to the requirements. These traces were not shown.

Here is the diagram with attributes. The Address attributes are not specified in the requirements so some reasonable attributes were used.

Finally, here is the diagram with operations.