270 likes | 414 Views
Data Modeling. Data Masters. Special Thanks To…. Planet Linux Caffe http :// planetlinuxcaffe.com. Short bio about me… Andrew Simkovsky 15 years working with database technology Worked across many industries Why Data Masters? Used to be a certification instructor – I miss it!
E N D
Data Modeling Data Masters
Special Thanks To… Planet Linux Caffe http://planetlinuxcaffe.com
Short bio about me… • Andrew Simkovsky • 15 years working with database technology • Worked across many industries • Why Data Masters? • Used to be a certification instructor – I miss it! • Sharing knowledge • Fostering a community
DBTekPro www.dbtekpro.com andrew@dbtekpro.com @asimkovsky
Quick History of the Relational Data Model • Early Data Systems – were actually file processing systems • Challenges: • Data retrieval • Portability • Data redundancy • Modification anomalies
Data Anomalies Jane Doe, 1 Oak St, Riverside, MN, shirt, X3JDK1, small, 2 Jane Doe, 1 Oak St, Riverside, MN, pants, X3JDK7, size 4, 1 Jane Doe, 1 Oak St, Riverside, MN, socks, X3JDK4, small, 1
Advent of the RDBMS • Separate logical from physical • Preserves natural relationships between pieces of data • System is a running database engine • Standardized data format • Standardized data retrieval and manipulation language • Avoids modification anomalies • Database is self-describing
Components of a Data Model • Entities - real world objects you want to store data about • Attributes – details for those entities • Relationships – a real world connection between entities • Relationship Context (verb forms) – description of the relationship between entities • Cardinality - how many of each entity is on each side of the relationship
Example Data Model contains classroom desk is used in room number length width height number of doors number of windows desk type width height number of seats
Cardinality 1:1 1:M M:N Zero Cardinality
Example Data Model contains classroom desk is used in room number length width height number of doors number of windows desk type width height number of seats
Cardinality Notation 0 or 1 1 and only 1 1 or more 0, 1, or more
Zero Cardinality CLASSROOM DESK 1 M 1 0 1 1 0 1 1:M
Example Data Model contains classroom desk is used in room number length width height number of doors number of windows desk type width height number of seats
Constraints • Constraints are used to enforce rules • A relationship can be considered a rule • Cardinality can be considered a rule • Forcing a specific value or values can be a rule
Types of Constraints • Primary key – single unique identifier per row • Alternate key – an attribute that can be used as an alternative to the primary key • Foreign key – pointer from one specific instance of an entity to a specific instance of another entity • Check constraint – ensure that only specific values are allowed in an attribute
Example Data Model contains classroom desk is used in desk id classroom id room number length width height number of doors number of windows desk type width height number of seats classroom id
Mapping Logical Data Model to Physical Database Entities Tables Attributes Columns Relationships Constraints
Normalization DEFINITION Refining a data model to reduce data modification anomalies
Data Anomalies Jane Doe, 1 Oak St, Riverside, MN, shirt, X3JDK1, small, 2 Jane Doe, 1 Oak St, Riverside, MN, pants, X3JDK7, size 4, 1 Jane Doe, 1 Oak St, Riverside, MN, socks, X3JDK4, small, 1
The Normal Forms • Set of rules to follow, in sequence, to eliminate modification anomalies • Normal forms are nested • If you can prove your data model is in one normal form, then its automatically in all lower normal forms
The Normal Forms • 1st Normal Form (1NF) • 2nd Normal Form (2NF) • 3rd Normal Form (3NF) • Boyce-Codd Normal Form (BCNF) • Fourth Normal Form (4NF) • Fifth Normal Form (5NF) • Domain Key Normal Form (DKNF) • 6th Normal Form (6NF)
Data Normalization http://en.wikipedia.org/wiki/Database_normalization
The Normal Forms 1NF 2NF 3NF BCNF 4NF 5NF DKNF 6NF
Normalization Process • Iterative in nature • Normalize for data efficiency • Denormalize for database performance • Differences between types of databases • Exceptions to normalization rules