16
Relational DB Components MMG 508

Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Embed Size (px)

Citation preview

Page 1: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Relational DB Components

MMG 508

Page 2: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Conceptual DB Design Components

To get started, look at the Conceptual Database Diagram on page 26 of the text, and on the next slide.

ComponentsEntitiesAttributesRelationships

Page 3: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Movie Rental Conceptual Design

Page 4: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Relationship Types

One-to-One RelationshipsThe generic definition of 1:1 relationships is:

This is an association where an instance of one entity can be associated with at most one instance of the other entity and vice versa

These are rare and anomaliesThese are normally corrected by combining the

entitiesFigure 2-2 on page 29 applies

Page 5: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

One-to-One Conditional

Figure on next slide shows a different “flavor” of one-to-one relationship that is optional (some say conditional) in both directions

The dealership issues automobiles to some employees, typically sales staff, for them to drive for a finite period.

We can read the relationship between the Employee and Automobile entities as follows:

“At any point in time, each employee can have zero or one automobiles issued to him or her, and each automobile can be assigned to zero or one employee.”

Note the clause “At any point in time.” If an automobile is taken back from one employee and then reassigned to another, this would still be a one-to-one relationship, albeit a transferable one. This is because when we consider relationships, we always think in terms of a snapshot taken at an arbitrary point in time.

Page 6: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

One-to-One Conditional (Cont’d)

Page 7: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Relationship Types (Cont’d)

One-to-Many relationships (1:m)Basic definition states that the 1:m

relationship is an association between two entities where any instance of the first entity may be associated with one or more instances of the second and any instance of the second entity may be associated with at most one instance of the first

See next slide

Page 8: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

One-to-Many (1:M) Diagram

Page 9: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Relationship Types (Cont’d)

Many-to-Many Relationships (n:m)Defined as an association between two

entities where any instance of the first entity may be associated with zero, one, or more instances of the second and vice versa.

Look at Figure 2-1, p. 26 (and next slide)Most common relationship

Page 10: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Many-to-Many (M:N) Relationship

Page 11: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Relationship Types (Cont’d)

Recursive RelationshipsCan be 1:1; 1:n, n:m relationshipsAre relationships within one entitySee Figure 2-4 p. 32

Page 12: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Business Rules

These are policies mandated by the organization

Look at Figure 2-1 on page 26This Business Rule states that “Customers

with overdue amounts may not book new orders”

Can be manually enforcedCan be enforced via program coding

Page 13: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Tables

This is the primary unit of storage for any RDBMS and is two dimensional

Relational tables are logical storage structures and usually do not exist in tabular form in the physical layer

Tables have unique names assigned by the DBA

See Figure 2-5 on page 34

Page 14: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Table Attributes

Table attributes are:ColumnsData typesConstraints

Primary Key constraintsReferential constraints

e.g. foreign keys

Intersection Tables (p. 42)

Page 15: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Integrity Constraints

Integrity ConstraintsNOT NULL constraints

Essentially, not null is used where a specific column cannot be blank

CHECK constraintsUsed for value validation in columnsSee p. 44 for example – also Figure 2-11

Page 16: Relational DB Components MMG 508. Conceptual DB Design Components To get started, look at the Conceptual Database Diagram on page 26 of the text, and

Views

A View is a virtual tableThis is a logical table which give a user

access to specific columns in a table or tables

MS Access view illustrated on p. 46, Figure 2-12