a practical introduction to transactional database modeling and design mike burr
Post on 15-Jan-2016
222 views
TRANSCRIPT
![Page 1: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/1.jpg)
A Practical Introduction to Transactional Database Modeling and Design
Mike Burr
![Page 2: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/2.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/3.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/4.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/6.jpg)
![Page 7: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/8.jpg)
![Page 9: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/10.jpg)
A Couple of Example Tables
![Page 11: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/11.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/12.jpg)
Two Important Notations
Microsoft Access
Crow’s Foot
![Page 13: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/14.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/15.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/16.jpg)
Example: Accounts Payable
![Page 17: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/17.jpg)
Store Clerk Logon and PO Validation(First Guess)
![Page 18: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/18.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/19.jpg)
Second Attempt After resolving many-to-many
![Page 20: A Practical Introduction to Transactional Database Modeling and Design Mike Burr](https://reader035.vdocuments.site/reader035/viewer/2022062423/56649d2f5503460f94a0679f/html5/thumbnails/20.jpg)
References
• [DMD] Toby Teorey, Sam Lightstone, and Tom Nadeau. Database Modeling and Design, 4 ed. Elsevier. 2006. ISBN 978-0-12-685352-0