Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Design Chapters 17 and 18.

Similar presentations


Presentation on theme: "Database Design Chapters 17 and 18."— Presentation transcript:

1 Database Design Chapters 17 and 18

2 Learning Objectives Learn the steps to design and implement a database system. Learn how is an entity-relationship (E-R) diagram is drawn. Learn how E-R diagrams are read and what they reveal about the business activities and policies of the organization being modeled

3 Database Design Process
Initial Planning – Need Feasibility (Technological and Economical) User Needs/Scope (# Users/#Transactions) Preliminary Hardware and Software Develop Schemas Conceptual, Internal, and External Translate internal schema into database structure Develop New Applications Transfer data from existing system to new AIS Test New System Train Employees Monitor System Performance Monitor User Satisfaction Identify Needs for System Enhancements and Modifications

4 Data Modeling Process of defining a database so that it faithfully represents all aspects of the organization, including its interactions with the external environment. Entity-relationship (E-R) diagrams REA data model

5 REA Modeling Resources Events Agents
Things that have economic value to the organization (e.g., inventory, cash) Events Various business activities that management wants to collect information on Agents People and organizations that participate in events (both internal (e.g., employees) and external (e.g., customers/vendors) to the organization) REA stands for Resource, Events, Agents. If you recall from Chapter 1, Figure 1-2 (on p. 7) actually depicts the various transaction cycles in the form of the “give-get” relationship of events for each subsystem of an AIS.

6 Review of Database Terms
entity, relation, table attribute, field, column tuple, record, row instance of an entity primary key foreign key relationship cardinality, modality

7 ENTITY-RELATIONSHIP DIAGRAMS
In an E-R diagram, entities are depicted as rectangles. But there are no industry standards for other aspects of these diagrams. Course Student

8 ENTITY-RELATIONSHIP DIAGRAMS
Sometimes attributes are listed in the same symbol as the entity itself. Course Course CRN (pk) Course Days Course Time Student Student ID No. (pk) Student Name Student Address This is the approach we will be using in this class. However many of the examples in these slides do not show attributes since the focus is on relationship issues. A final ERD should show all attributes of each entity.

9 RELATIONSHIPS A relationship is a natural business association that exists between one or more entities. Entities are connected by a line Should use active verbs to describe the relationship One verb can describe the relationship in both directions Customer Order Places

10 CARDINALITY Cardinality describes the maximum number of instances of one entity that may be related to a specific instance of another entity. For example, the cardinalities between Order and Customer answer the questions: How many customers can be associated with a single order that a company receives? How many orders can be associated with a single customer of the company?

11 MODALITY Modality describes the minimum number of instances of one entity that can be related to a specific instance of another entity. For example, the cardinality between Order and Customer answers the questions: Does each order have to be associated with a customer? Does each customer have to be associated with an order?

12 CARDINALITY and MODALITY
Using the crow’s feet notation: The symbol for zero is a circle: O The symbol for one is a single stroke: | The symbol for many is the crow’s foot:

13 CARDINALITY and MODALITY
Order Customer is placed by Because all relationships are bidirectional, modality and cardinality must be defined in both directions for every relationship.

14 CARDINALITY and MODALITY
Order Customer is placed by The modality symbol next to customer is the symbol for one. This symbol means that for every occurrence of an order, there must be a minimum of one customer involved.

15 CARDINALITY and MODALITY
Order Customer is placed by The cardinality symbol next to customer is the symbol for one. This symbol means that for every occurrence of an order, there can be no more than one customer involved.

16 CARDINALITY and MODALITY
Order Customer is placed by The modality symbol next to order is the symbol for zero. This symbol means that for every customer in the database, there must be a minimum of zero orders. This minimum of zero allows the company to add a customer to its database before any orders have been placed by that customer, i.e., a prospective customer can be included.

17 CARDINALITY and MODALITY
Order Customer is placed by The cardinality symbol next to order is the symbol for many. This symbol means that for every customer in the database, there can be many orders involved. Obviously, a company can allow multiple orders from an individual customer.

18 CARDINALITY and MODALITY
Places Customer Order Claims Employee Dependent Teaches Instructor Section Claims Employee Dependent

19 CARDINALITY and MODALITY
It is not a “one size fits all” world for relationships and cardinalities. The cardinalities between two entities can vary based on how the particular company does business. It reflects facts about the organization that are obtained during the requirements definition stage of the database design process.

20 CARDINALITY and MODALITY
Customers pay for each sale with a maximum of one payment (typical for retail stores). Each cash receipt from a customer relates to one (and only one) sale. Sale Cash Receipt Simple Convenience Store Sale.

21 CARDINALITY and MODALITY
Customers pay for each sale with a maximum of many payments (installments). Each cash receipt from a customer relates to one (and only one) sale. Sale Cash Receipt Installment Sales (One item, many payments).

22 CARDINALITY and MODALITY
Customers make only one payment for a sale. Each cash receipt from a customer can relate to multiple sales (e.g., they pay for all sales that month in one payment). Sale Cash Receipt Customer pays once a month for all transactions that occurred that month.

23 CARDINALITY and MODALITY
Customers may make multiple payments for a particular sale. A cash receipt from a customer may relate to more than one sale. Sale Cash Receipt

24 CARDINALITY and MODALITY
Three Types of Relationships Three types of relationships are possible between entities. Relationships depend on the cardinality on each side of a relationship. A one-to-one relationship (1:1) exists when the maximum cardinality for each entity in the relationship is 1. A one-to-many (1:N) relationship exists when the maximum cardinality on one side is 1 and the maximum on the other side is many. A many-to-many (M:N) relationship exists when the maximum on both sides is many.

25 CARDINALITY and MODALITY
College Both cardinalities are one, so this is a one-to-one relationship. Dean

26 CARDINALITY and MODALITY
Order Customer The maximum number of customers that can be involved in each order is one. The maximum number of orders that can be associated with any individual customer is many. This is a one-to-many (1:N) relationship.

27 CARDINALITY and MODALITY
Inventory Sale The maximum number of inventory items that can be sold in one sale is many. The maximum number of sales that can occur for a particular inventory item is many. This is a many-to-many (M:N) relationship.

28 Implement One-to-One Relationships
In a relational database, one-to-one relationships between entities can be implemented by merging the two tables/entities together.

29 Implement One-to-Many Relationships
One-to-many relationships between entities can be implemented by placing the primary key of the entity that can occur only once as a foreign key in the entity that can occur many times. EXAMPLE: The primary key for salesperson (which can occur only once per sale) is a foreign key in the sale table/entity (which can occur many times for a particular salesperson). If you tried to do the opposite, you would not have single-valued entries in the tables

30 Implement One-to-Many Relationships
!

31 Implement Many-to-Many Relationships
In a relational database, many-to-many relationships between entities can be implemented by creating a new entity that links the other two entities together. In most cases, the primary key of the new entity consists of the concatenated primary key attributes of the entities that it is relating together. The table/entity names for M:N relationships should be hyphenated concatenations of the entities involved in the relationship.

32 Implement Many-to-Many Relationships
Student Student ID (pk) Student first name Student last name Section Section CRN (pk) Section day Section time registers for Student Student ID (pk) Student first name Student last name Student-Section Student ID (pk)(fk) Section CRN (pk)(fk) Section Section CRN (pk) Section day Section time participates in Is for a

33 SUMMARY: DESIGNING AN E-R Diagram
Create an entity for each distinct thing (people, places, events, etc.) that the organization wants to track. Identify a primary key for each entity Assign non-key attributes to appropriate entities Using knowledge of business processes identify relationships between entities and assign modality and cardinality to each relationship. Merge one-to-one relationships together and use foreign keys to implement one-to-many relationships. Draw new entities to handle with many-to-many relationships and add appropriate attributes, cardinalities, modalities, etc. Create tables (one for each entity on the ERD) for sample data and check for rule violations or anomalies


Download ppt "Database Design Chapters 17 and 18."

Similar presentations


Ads by Google