Home > Data Modeler Tutorial: Mode... > Develop the Logical Model
The logical model for the database includes three entities: Books (describes each book in the library), Patrons (describes each person who has a library card), and Transactions (describes each transaction involving a patron and a book). However, before you create the entities, create some domains that will make the entity creation (and later DDL generation) more meaningful and specific.
To start developing the logical model, go to Adding Domains.
In planning for your data needs, you have determined that several kinds of fields will occur in multiple kinds of records, and many fields can share a definition. For example, you have decided that:
The first and last names of persons can be up to 25 characters each.
Street address lines can be up to 40 characters.
City names can be up to 25 characters.
State codes (United States) are 2-character standard abbreviations.
Zip codes (United States postal codes) can be up to 10 characters (nnnnn-nnnn).
Book identifiers can be up to 20 characters.
Other identifiers are numeric, with up to 7 digits (no decimal places).
Titles (books, articles, and so on) can be up to 50 characters.
You therefore decide to add appropriate domains, so that you can later use them to specify data types for attributes when you create the entities. (These added domains will also be available after you exit Data Modeler and restart it later.)
Click Tools, then Domains Administration.
In the Domains Administration dialog box, add domains with the following definitions. Click Add to start each definition, and click Apply after each definition.
Name | Logical Type | Other Information |
---|---|---|
Person Name | VARCHAR | Size: 25 |
Address Line | VARCHAR | Size: 40 |
City | VARCHAR | Size: 25 |
State | VARCHAR | Size: 2 |
Zip | VARCHAR | Size: 10 |
Book Id | VARCHAR | Size: 20 |
Numeric Id | NUMERIC | Precision: 7, Scale: 0 |
Title | VARCHAR | Size: 50 |
When you have finished defining these domains, click Save. This creates a file named defaultdomains.xml
in the datamodeler/domains
directory or datamodeler\domains
folder under the location where you installed Data Modeler.
Optionally, copy the defaultdomains.xml
file to a new location (not under the Data Modeler installation directory), and give it an appropriate name, such as library_domains.xml
. You can then import domains from that file when you create other designs.
Click Close to close the dialog box.
Go to Creating the Books Entity.
The Books entity describes each book in the library. Create the Books entity as follows:
In the main area (right side) of the Data Modeler window, click the Logical tab.
Click the New Entity icon.
Click in the logical model pane in the main area; and in the Logical pane press, diagonally drag, and release the mouse button to draw an entity box. The Entity Properties dialog box is displayed.
Click General on the left, and specify as follows:
Name: Books
Click Attributes on the left, and use the Add (+) icon to add the following attributes, one at a time. (For datatypes, select from the Domain types except for Rating, which is a Logical type.)
Name | Datatype | Other Information and Notes |
---|---|---|
book_id | Domain: Book Id | Primary UID (unique identifier). (The Dewey code or other book identifier.) |
title | Domain: Title | M (mandatory, that is, must not be null). |
author_last_name | Domain: Person Name | M (mandatory, that is, must not be null). |
author_first_name | Domain: Person Name | (Author's first name; not mandatory, but enter it if the author has a first name.) |
rating | Logical type: NUMERIC (Precision=2, Scale= 0) | (Librarian's personal rating of the book, from 1 (poor) to 10 (great).) |
Click OK to finish creating the Books entity.
Go to Creating the Patrons Entity.
The Patrons entity describes each library patron (that is, each person who has a library card and is thus able to borrow books). Create the Patrons entity as follows:
In the main area (right side) of the Data Modeler window, click the Logical tab.
Click the New Entity icon.
Click in the logical model pane in the main area; and in the Logical pane press, diagonally drag, and release the mouse button to draw an entity box. (Suggestion: draw the box to the right of the Books box.) The Entity Properties dialog box is displayed.
Click General on the left, and specify as follows:
Name: Patrons
Click Attributes on the left, and use the Add (+) icon to add the following attributes, one at a time. (For datatypes, select from the Domain types, except for location, which uses the structured type SDO_GEOMETRY.)
Attribute Name | Type | Other Information and Notes |
---|---|---|
patron_id | Domain: Numeric Id | Primary UID (unique identifier). (Unique patron ID number, also called the library card number.) |
last_name | Domain: Person Name | M (mandatory, that is, must not be null). 25 characters maximum. |
first_name | Domain: Person Name | (Patron's first name.) |
street_address | Domain: Address Line | (Patron's street address.) |
city | Domain: City | (City or town where the patron lives.) |
state | Domain: State | (2-letter code for the state where the patron lives.) |
zip | Domain: Zip | (Postal code where the patron lives.) |
location | Structured type: SDO_GEOMETRY | Oracle Spatial geometry object representing the patron's geocoded address. |
Click OK to finish creating the Patrons entity.
The Transactions entity describes each transaction that involves a patron and a book, such as someone checking out or returning a book. Each record a single transaction, regardless of how many books the patron brings to the library desk. For example, a patron returning two books and checking out three books causes five transactions to be recorded (two returns and three checkouts). Create the Transactions entity as follows:
In the main area (right side) of the Data Modeler window, click the Logical tab.
Click the New Entity icon.
Click in the logical model pane in the main area; and in the Logical pane press, diagonally drag, and release the mouse button to draw an entity box. (Suggestion: Draw the box below and centered between the Books and Patrons boxes.) The Entity Properties dialog box is displayed.
Click General on the left, and specify as follows:
Name: Transactions
Click Attributes on the left, and use the Add (+) icon to add the following attributes, one at a time. (For datatypes, select from the Domain types, except for transaction_date, which uses a Logical type.)
Attribute Name | Type | Other Information and Notes |
---|---|---|
transaction_id | Domain: Numeric Id | Primary UID (unique identifier). (Unique transaction ID number) |
transaction_date | Logical type: Datetime | M (mandatory, that is, must not be null). Date and time of the transaction. |
transaction_type | Domain: Numeric Id | M (mandatory, that is, must not be null). (Numeric code indicating the type of transaction, such as 1 for checking out a book.) |
Note that you do not explicitly define the patron_id and book_id attributes, because these will be automatically added to the Transactions entity after you create relations between the entities (see Creating Relations Between Entities); they will be added as foreign keys when you generate the relational model (see Develop the Relational Model).
Click OK to finish creating the Transactions entity.
Relations show the relationships between entities: one-to-many, many-to-one, or many-to-many. The following relationships exist between the entities:
Books and Transactions: one-to-many. Each book can be involved in multiple sequential transactions. Each book can have zero or one active checkout transactions; a book that is checked out cannot be checked out again until after it has been returned.
Patrons and Transactions: one-to-many. Each patron can be involved in multiple sequential and simultaneous transactions. Each patron can check out one or many books in a visit to the library, and can have multiple active checkout transactions reflecting several visits; each patron can also return checked out books at any time.
Create the relationships as follows. When you are done, the logical model pane in the main area should look like the following figure. Note that for this figure, Bachman notation is used (you can change to Barker by clicking View, then Logical Diagram Notation, then Barker Notation).
In the logical model pane in the main area, arrange the entity boxes as follows: Books on the left, Patrons on the right, and Transactions either between Books and Patrons or under them and in the middle. (If the pointer is still cross-hairs, click the Select icon at the top left to change the pointer to an arrow.)
Suggestion: Turn off auto line routing for this exercise: right-click in the Logical pane, and ensure that Auto Route is not checked.
Click the New 1:N Relation icon.
Click first in the Books box, then in the Transactions box. A line with an arrowhead is drawn from Books to Transactions.
Click the New 1:N Relation icon.
Click first in the Patrons box, then in the Transactions box. A line with an arrowhead is drawn from Patrons to Transactions.
Optionally, double-click a line (or right-click a line and select Properties) and view the Relation Properties information.
Go to Develop the Relational Model.
Related Topics