04.06.2015 Views

Database Modeling and Design

Database Modeling and Design

Database Modeling and Design

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

106 CHAPTER 5 Transforming the Conceptual Data Model to SQL<br />

5.3 Summary<br />

Entities, attributes, <strong>and</strong> relationships in the ER model <strong>and</strong> classes,<br />

attributes, <strong>and</strong> associations in UML can be transformed directly into SQL<br />

(SQL-99) table definitions with some simple rules. Entities are transformed<br />

into tables, with all attributes mapped one-to-one to table<br />

attributes. Tables representing entities that are the child (“many” side) of<br />

a parent-child (one-to-many or one-to-one) relationship must also<br />

include, as a foreign key, the primary key of the parent entity. A manyto-many<br />

relationship is transformed into a table that contains the primary<br />

keys of the associated entities as its composite primary key; the<br />

components of that key are also designated as foreign keys in SQL. A ternary<br />

or higher-level n-ary relationship is transformed into a table that<br />

contains the primary keys of the associated entities; these keys are designated<br />

as foreign keys in SQL. A subset of those keys can be designated as<br />

the primary key, depending on the functional dependencies associated<br />

with the relationship. Rules for generalization require the inheritance of<br />

the primary key from the supertype to the subtype entities when transformed<br />

into SQL tables. Optionality constraints in the ER or UML diagrams<br />

translate into nulls allowed in the relational model when applied<br />

to the “one” side of a relationship. In SQL, the lack of an optionality<br />

constraint determines the not null designation in the create table definition.<br />

5.4 Literature Summary<br />

Definition of the basic transformations from the ER model to tables is<br />

covered in McGee [1974], Wong <strong>and</strong> Katz [1979], Sakai [1983], Martin<br />

[1983], Hawryszkiewyck [1984], Jajodia <strong>and</strong> Ng [1984], <strong>and</strong> for UML in<br />

Muller [1999].<br />

@Spy

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!