Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
In designing databases, we begin by examining the entities that are of importance to an organization. A conceptual data model is created to capture the overall structure of the entities and the relationships among them
Characteristics of the entities Relationships among the entities How the database will be physically stored The data model used to implement the database The type of DBMS to be used
3
Independent of :
Entities Relationships among entities Attributes of both the entities and their relationships
Entity
An entity is a person, place, thing, or event which an organization wishes to maintain data about Examples:
STUDENT
SUBJECT
Entity type
A collection of all occurrences of a given type of entity Also known as entity class
A single occurrence of an entity type An entity type can have many instances
Entity instance
Attributes
Name
STUDENT
Address
Birthday
7
Value of an Attribute
The ERD contains only the attribute type and not its values
8
Multivalued vs. single-valued Composite vs. simple (or atomic) Derived vs. stored
Multivalued Attributes
Attributes having more than one value for each entity instance Example:
10
Composite Attributes
11
12
Derived Attribute
Derived
from date employed and current date
13
The relational model uses primary keys to link related entities together Primary key - an attribute or a combination of attributes that uniquely identifies an instance of an entity Represented by underlining the attribute(s) involved
ID_Num
14
Unique - no two entity instances can have the same value for the primary key attribute Not null Must not change over time Avoid use of intelligent keys Substitute new, simple keys for long, composite keys
15
Relationship
A relationship is a natural association between the instances of one or more entities Example:
STUDENT
enrolls
SUBJECT
Degree of a Relationship
The number of entity types attached to a relationship Three (3) most common types
17
Unary Relationship
A recursive relationship within a single entity Exists within an entity to link related instances of that entity together
PERSON
is married to
18
Binary Relationship
STUDENT
enrolls
SUBJECT
19
Ternary Relationship
VENDOR
ships
WAREHOUSE
20
Optional Relationship
An instance of one entity may not be associated with an instance of the related entity
Every instance in one entity type must be associated with at least one instance in the related entity
Mandatory Relationship
21
Types of Relationship
Three (3) possible types of relationship can exist between the occurrences of related entity types:
22
Cardinality
The number of instances that is associated between a pair of entity types The cardinality of the association from A to B is the maximum number of occurrences of B that can be associated with A A pair of associations can exist between any two entities:
Examples of Cardinality
24
25
26
Optional cardinality
If minimum cardinality is 0
If minimum cardinality is 1
Mandatory cardinality
Mandatory 1 cardinality
27
Multiple Relationships
30
Strong entities
Exist independently of other types of entities Has its own unique identifier Represented with single-line rectangle Dependent on a strong entitycannot exist on its own; has no business meaning in the ERD without the entity (called identifying owner) it depends on Does not have a unique identifier, only partial identifier Represented with double-line rectangle Links strong entities to weak entities Represented with double line diamond
31
Weak entity
Identifying relationship
Strong entity
Identifying relationship
Weak entity
32
Also known as composite entity A many-to-many relationship modeled as an entity type It is a relationship (but would want to maintain data about) It is an entity in disguise Has independent meaning to end-users and preferably identifiable by a single attribute
SHIPMENT
33
EMP
completes
COURSE
Emp #
Name
Date Completed
Course ID
Title
EMP
CERTIFICATE
COURSE
Certificate #
34
35
36
Subtype: A subgroup an entity type which has attributes that are distinct from those in other subgroups Supertype: An generic entity type that has a relationship with one or more subtypes Inheritance
Subtype entities inherit values of all attributes of the supertype An instance of a subtype is also an instance of the supertype
37
Basic Notation
38
Relationships at the supertype level indicate that all subtypes will participate in the relationship The instances of a subtype may participate in a relationship unique to that subtype. In this situation, the relationship is shown at the subtype level
39
40
Generalization
The process of defining a more general entity type from a set of more specialized entity type (bottom-up)
The process of defining one or more subtypes of the supertype and forming supertype/subtype relationships (topdown)
41
Specialization
Completeness Constraints
Total Specialization Rule: Yes (double line) Partial Specialization Rule: No (single line)
42
43
44
Disjointness Constraints
Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes Disjoint Rule: An instance of the supertype can be only ONE of the subtypes Overlap Rule: An instance of the supertype could be more than one of the subtypes
45
Disjointness Constraints
46
Overlap Constraints
47
Subtype Discriminator: An attribute of the supertype whose values determine the target subtype(s) Two types:
Disjoint a simple attribute with alternative values to indicate the possible subtypes Overlapping a composite attribute whose subparts pertain to different subtypes; each subpart contains a boolean value to indicate whether the instance belongs to associated subtype
48
49
A composite attribute with sub-attributes indicating yes or no to determine whether it is of each subtype
50
Supertype/Subtype Hierarchy
51
Entity Clusters
52
Inappropriate Diagrams
System user
System output
contain a user of the system contain an output of the database system (e.g. a report) be confused with a user view
53