Top Banner
A Practical Introduction to Transactional Database Modeling and Design Mike Burr
20

A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Jan 15, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

A Practical Introduction to Transactional Database Modeling and Design

Mike Burr

Page 2: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Database Design

• Create a structure to model and store data about a part of the real world.

Example of data: 35, “tall and skinny”, 9/16/1975.

• Data is not useful without context.• The model (and resulting database) is used to

generate information.

Page 3: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

The Waterfall

• Project Planning• Requirements Analysis• Design and Development• Implementation• Operation and Maintenance

Page 4: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Big Ideas…

• Databases are rarely used in isolation from an application.

• Most modern databases are implemented on multiuser relational database management systems where access can be granted at a granular level

• One of the main goals of transactional database design is normalization (ensuring that data is stored efficiently and transactions are free from insert, update, and delete anomolies)

Page 5: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Basic Ideas

• Entity: An object in the real world that we might want to collect information about. Examples are people, cars, loans, transactions, etc.

• Relationship: A real world association between two or more entities to be captured in the database

• Attribute: A characteristic of an entity that needs to be captured in the database

Page 6: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.
Page 7: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Basic Ideas

• Primary Key: One or more attributes that uniquely identify an instance of an entity (or a row in a table)

- Two Types: natural and artificial• Foreign Key: An attribute in an entity that

references an attribute in another table. Usually used to enforce referential integrity.

Page 8: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.
Page 9: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Mapping from ER Concepts to Table Concepts

• Entity -> Table• Attribute -> Column• Relationship -> Foreign Key Constraint or

Trigger

Page 10: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

A Couple of Example Tables

Page 11: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Basic Ideas

• Actors are the particular people (accountants, shipping clerks, vendor*) or systems that will create or use data from the model

• View (from the perspective of a data model): A collection of entities and relationships that a particular actor in a system is interested in.

• View (from a SQL perspective): An artificial table created from joining one or more tables that can be used in other queries. More on this later with the discussion of SQL…

Page 12: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Two Important Notations

Microsoft Access

Crow’s Foot

Page 13: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Cardinality

Zero or One

Zero or more

Exactly One

One or more

Page 14: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

General Design Procedure

• Identify all of the relevant actors for the system

• Determine the entities, attributes, and relationships from the perspective of each actor

• Combine the views to form the model

Page 15: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Guidelines

• Attributes may not have attributes of their own, this implies that entities may need to be created (1NF)

• All attributes must depend on the primary key (2NF). If attributes are not dependent on primary key, then more entities may need to be created.

• The primary key must identify the entire row and many-to-many relationships must be resolved to maintain data integrity.

Page 16: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Example: Accounts Payable

Page 17: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Store Clerk Logon and PO Validation(First Guess)

Page 18: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Problems with First Guess

• Impossible to know how many of each item is included on PO• If price is included in PO, then prices cannot be itemized on an invoice• If price is included in Item, then any change to the price will result in

a change to all POs, past, present, and future. • Quantities cannot be tracked• Root issue is known as a “many to many relationship”• Prices and quantities are not attributes of the PO nor the item (3NF

violation)

Problem:

Page 19: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

Second Attempt After resolving many-to-many

Page 20: A Practical Introduction to Transactional Database Modeling and Design Mike Burr.

References

• [DMD] Toby Teorey, Sam Lightstone, and Tom Nadeau. Database Modeling and Design, 4 ed. Elsevier. 2006. ISBN 978-0-12-685352-0