Professional Documents
Culture Documents
Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel
A data model is the relatively simple representation, usually graphic, of complex real-world data structures. It represents data structures and their characteristics, relations, constraints, and transformations.
The database designer usually employs data models as communications tools to facilitate the interaction among the designer, the applications programmer, and the end user. A good database is the foundation for good applications.
4
Figure 4.1 Four Modified (ANSI/SPARC) Data Abstraction Models
The conceptual model represents a global view of the data. It is an enterprise-wide representation of data as viewed by high-level managers. Entity-Relationship (E-R) model is the most widely used conceptual model. The conceptual model forms the basis for the conceptual schema. The conceptual schema is the visual representation of the conceptual model. The conceptual model is independent of both software (software independence) and hardware (hardware independence).
4
Figure 4.2
4
Figure 4.3
The internal model adapts the conceptual model to a specific DBMS. The internal model is software-dependent.
Development of the internal model is especially important to hierarchical and network database models.
Figure 4.4
The external model is the end users view of the data environment.
Each external model is then represented by its own external schema.
CREATE VIEW CLASS_VIEW AS SELECT (CLASS_ID, CLASS_NAME, PROF_NAME, CLASS_TIME, ROOM_ID) FROM CLASS, PROFESSOR, ROOM WHERE CLASS.PROF_ID = PROFESSOR.PROF_ID AND CLASS.ROOM_ID = ROOM.ROOM_ID;
It facilitates the designers task by making it easier to identify specific data required to support each business units operations.
It makes the designers job easier by providing feedback about the conceptual models adequacy. It helps to ensure security constraints in the database design.
The physical model operates at the lowest level of abstraction, describing the way data is saved on storage media such as disks or tapes. It requires the definition of both the physical storage devices and the access methods required to reach the data within those storage devices. The physical model is both software and hardware-dependent. It requires detailed knowledge of hardware and software used to implement the database design.
Translate different views of data among managers, users, and programmers to fit into a common framework.
Define data processing and constraint requirements to help us meet the different views.
Help implement the database.
Entities
In E-R models an entity refers to the entity set. An entity is represented by a rectangle containing the entitys name.
Attributes
Attributes are represented by ovals and are connected to the entity with a line. Each oval contains the name of the attribute it represents. Attributes have a domain -- the attributes set of possible values. Attributes may share a domain. Primary keys are underlined.
Relationships
4
Figure 4.6
4
Figure 4.7
4
Figure 4.8
Examples: ADDRESS Street, City, State, Zip PHONE NUMBER Area code, Exchange number
Examples: A person can have only one social security number. A manufactured part can have only one serial number.
Examples: A person may have several college degrees. A household may have several phones with different numbers
The relational DBMS cannot implement multivalued attributes. Possible courses of action for the designer
Within the original entity, create several new attributes, one for each of the original multivalued attributes components (Figure 4.9). Create a new entity composed of the original multivalued attributes components (Figure 4.10).
Table 4.1
4
Figure 4.9
4
Figure 4.10
A derived attribute is not physically stored within the database; instead, it is derived by using an algorithm.
Example: AGE can be derived from the data of birth and the current date.
A unary relationship exists when an association is maintained within a single entity. A binary relationship exists when two entities are associated. A ternary relationship exists when three entities are associated.
4
Figure 4.14
The term connectivity is used to describe the relationship classification (e.g., one-to-one, one-tomany, and many-to-many).
Cardinality expresses the specific number of entity occurrences associated with one occurrence of the related entity.
Figure 4.17
Existence Dependency
If an entitys existence depends on the existence of one or more other entities, it is said to be existencedependent.
4
Figure 4.18
The participation is optional if one entity occurrence does not require a corresponding entity occurrence in a particular relationship. An optional entity is shown by a small circle on the side of the optional entity.
4
Figure 4.21 COURSE and CLASS in a Mandatory Relationship
Is existence-dependent and Has a primary key that is partially or totally derived from the parent entity in the relationship.
4
Figure 4.22
4
Figure 4.23
A recursive entity is one in which a relationship can exist between occurrences of the same entity set. A recursive entity is found within a unary relationship.
Figure 4.25
Figure 4.26
4
Figure 4.27
4
Figure 4.28
4
Figure 4.29
A composite entity is composed of the primary keys of each of the entities to be connected.
The composite entity serves as a bridge between the related entities.
4
Figure 4.30
4
Figure 4.31
4
Figure 4.32
4
Figure 4.33 Nulls Created by Unique Attributes
A subtype entity inherits its attributes and its relationships from the supertype entity.
A Generalization Hierarchy
4
Figure 4.34
The supertype entity set is usually related to several unique and disjointed (nonoverlapping) subtype entity sets. The supertype and its subtype(s) maintain a 1:1 relationship.
4
Figure 4.35
The supertype entity set is usually related to several unique and disjointed (nonoverlapping) subtype entity sets.
The supertype and its subtype(s) maintain a 1:1 relationship.
4
Figure 4.36
Figure 4.37
Chapter 4
Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel
Tiny College (TC) is divided into several schools. Each school is administered by a dean. A 1:1 relationship exists between DEAN and SCHOOL.
Each dean is a member of a group of administrators (ADMINISTRATOR). Deans also hold professorial rank and may teach a class (PROFESSOR). Administrators and professors are also Employees. (Figure 4.38)
Each school is composed of several departments. The smallest number of departments operated by a school is one, and the largest number of departments is indeterminate (N). Each department belongs to only a single school.
4
Figure 4.41 The Second Tiny College ERD Segment
A department may offer several sections (classes) of the same course. A 1:M relationship exists between COURSE and CLASS. CLASS is optional to COURSE
Each department has many professors assigned to it. One of those professors chairs the department. Only one of the professors can chair the department. DEPARTMENT is optional to PROFESSOR in the chairs relationship.
Each professor may teach up to four classes, each one a section of a course. A professor may also be on a research contract and teach no classes.
A student may enroll in several classes, but (s)he takes each class only once during any given enrollment period. Each student may enroll in up to six classes and each class may have up to 35 students in it. STUDENT is optional to CLASS.
Each department has several students whose major is offered by that department. Each student has only a single major and associated with a single department.
Each student has an advisor in his or her department; each advisor counsels several students. An advisor is also a professor, but not all professors advise students.
4
Table 4.2
Figure 4.48
A painter might paint many paintings. The cardinality is (1,N) in the relationship between PAINTER and PAINTING. Each painting is painted by one (and only one) painter. A painting might (or might not) be exhibited in a gallery; i.e., the GALLERY is optional to PAINTING.
Figure 4.49
PAINTER(PRT_NUM, PRT_LASTNAME, PRT_FIRSTNAME, PRT_INITIAL, PTR_AREACODE, PRT_PHONE) GALLERY(GAL_NUM, GAL_OWNER, GAL_AREACODE, GAL_PHONE, GAL_RATE) PAINTING(PNTG_NUM, PNTG_TITLE, PNTG_PRICE, PTR_NUM, GAL_NUM)
4
Table 4.3
1. All primary keys must be defined as NOT NULL. 2. Define all foreign keys to conform to the following requirements for binary relationships.
Create the foreign key by putting the primary key of the one (parent) in the table of the many (dependent). Foreign Key Rules:
Null On Delete RESTRICT On Update CASCADE
If both sides are MANDATORY If both sides are OPTIONAL If one side is OPTIONAL and the other MANDATORY
NOT NULL
SET NULL
CASCADE
CASCADE
Put the key of the parent table (strong entity) in the weak entity. The weak entity relationship conforms to the same rules as the 1:M relationship, except foreign key restrictions:
NOT NULL ON DELETE CASCADE ON UPDATE CASCADE
M:N Relationship
Convert the M:N relationship to a composite (bridge) entity consisting of (at least) the parent tables primary keys.
If both entities are in mandatory participation in the relationship and they do not participate in other relationships, it is most likely that the two entities should be part of the same entity.
4
Figure 4.50 Entity Relationships, M:N, Both Sides Mandatory
4
Figure 4.51 Entity Relationships, M:N, Both Sides Optional
4
Figure 4.52 Entity Relationships, M:N, One Side Optional
4
Figure 4.53 Entity Relationships, 1:M, Both Sides Mandatory
4
Figure 4.54 Entity Relationships, 1:M, Both Sides Optional
4
Figure 4.55
Entity Relationships, 1:M, Many Side Optional, One Side Mandatory
4
Figure 4.56
Entity Relationships, 1:M, One Side Optional, Many Side Mandatory
4
Figure 4.57 Entity Relationships, 1:1, Both Sides Mandatory
4
Figure 4.58 Entity Relationships, 1:1, Both Sides Optional
4
Figure 4.59
Entity Relationships, 1:1, One Side Optional, One Side Mandatory
4
Figure 4.60 Entity Relationships, Weak Entity
4
Figure 4.61 Entity Relationships, Multivalued Attributes
4
Figure 4.63
4
Figure 4.64
4
Figure 4.65 The Rein85 Representation of the Invoicing Problem
4
Figure 4.66
Design Considerations
Logical requirements and design conventions End user requirements; e.g., performance, security, shared access, data integrity Processing requirements Operational requirements Documentation