Entity Sets
A database can be modeled as:
a collection of entities, relationship among entities.
An entity is an object that exists and is distinguishable from other
objects.
Example: specific person, company, event, plant
Entities have attributes
Example: people have names and addresses
An entity set is a set of entities of the same type that share the
same properties.
Example: set of all persons, companies, trees, holidays
2.1
Entity Sets customer and loan
customer-id customer- customer- customername street city loan- amount number
2.2
Attributes
An entity is represented by a set of attributes, that is descriptive
properties possessed by all members of an entity set. Example: customer = (customer-id, customer-name, customer-street, customer-city) loan = (loan-number, amount)
Domain the set of permitted values for each attribute
Attribute types:
Simple and composite attributes. Single-valued and multi-valued attributes E.g. multivalued attribute: phone-numbers Derived attributes Can be computed from other attributes E.g. age, given date of birth
2.3
Composite Attributes
2.4
Relationship Set borrower
2.5
Mapping Cardinalities
Express the number of entities to which another entity can be
associated via a relationship set.
Most useful in describing binary relationship sets. For a binary relationship set the mapping cardinality must be
one of the following types:
One to one
One to many Many to one Many to many
2.6
Mapping Cardinalities
One to one
One to many
Note: Some elements in A and B may not be mapped to any elements in the other set
2.7
Mapping Cardinalities
Many to one
Many to many
Note: Some elements in A and B may not be mapped to any elements in the other set
2.8
Keys
A super key of an entity set is a set of one or more attributes
whose values uniquely determine each entity.
A candidate key of an entity set is a minimal super key
Customer-id is candidate key of customer
account-number is candidate key of account
Although several candidate keys may exist, one of the
candidate keys is selected to be the primary key.
So one key is selected as primary key and others are called
alternate keys
2.9
Keys for Relationship Sets
The combination of primary keys of the participating entity sets
forms a super key of a relationship set.
(customer-id, account-number) is the super key of depositor
NOTE: this means a pair of entity sets can have at most one relationship in a particular relationship set.
E.g. if we wish to track all access-dates to each account by each
customer, we cannot assume a relationship for each access. We can use a multivalued attribute though
Must consider the mapping cardinality of the relationship set
when deciding the what are the candidate keys
Need to consider semantics of relationship set in selecting the
primary key in case of more than one candidate key
2.10