Databases Reference
In-Depth Information
Exhibit 12-5.
Equivalent Concepts and terminology between entity-relationship
and relational diagrams.
Entity-Relationship Concepts
Relational Concepts
Entity set
Table
Entity
Row of a table
Attribute
Column of a table
Unique identifier
Primary key, candidate key
One-to-many relationship
Foreign key constraint
Many-to-many relationship
Two foreign keys referencing a linking table
Partial participation
No NOT NULL declaration in a relationship for a foreign
key
Total participation
NOT NULL declaration in a relationship for a foreign key
Weak entity
Primary key is a composite key containing the primary
key of another table
Class hierarchy
Two tables have the same primary key, one of which is
the foreign key of the contained table
In the example above, the entities Jones, Smith, and Lewis are members of
the Employee entity set, while entities Accounting and Sales are members
of the Department entity set.
Exhibit 6 shows the Employee entity set described using each of the four
design languages. The English text describes the Employee entity set as
having four attributes: Employee Identification, Employee Name, Address,
and Social Security Number. The entity-relationship diagram represents
the entity set as a rectangle labeled Employee with its attributes shown as
ovals labeled EmpId, EmpName, Address, and SocialSecurityNumber.
Attribute ovals are connected to the entity that they describe. The SQL
CREATE TABLE statement describes the same entity set as a table consist-
ing of four columns. The relational diagrams illustrate the Employee table
by showing a box with table name Employee at the top and column head-
ings EmpId, EmpName, Address, and SocialSecurityNumber at the bottom
of the box.
Key Constraint
Exhibit 7 extends the entity set presented in Exhibit 6 to include the con-
cept of a key constraint, which is used to enforce uniqueness among enti-
ties in an entity set. A key constraint specifies that no two entities in an
entity set can have the same value for the key attribute. (A key is a subset
of the attributes in the entity set.) In English, a constraint is specified by a
sentence in the form of “No two <entities> may have the same value for
<attribute>“ or “<attribute> uniquely identifies <entity>.” With entity-rela-
tionship diagrams, the attribute name of the unique identifier is under-
lined. In SQL, the clause PRIMARY KEY <attribute> identifies the unique
 
Search WWH ::




Custom Search