Relational Database Concepts

IBM Information Management Cloud Computing Center of Competence IBM Canada Labs
1
© 2011 IBM Corporation

Agenda
• Overview • Information and Data Models • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization

2

© 2011 IBM Corporation

Supporting reading material & videos
• Reading materials • Database Fundamentals eBook
• • • • Chapter 1: Databases and information models Chapter 2: The relational data model Chapter 3: The conceptual data model (optional) Chapter 4: Relational database design (optional)

• Videos • db2university.com course AA001EN
• Lesson 1: Relational database concepts

3

© 2011 IBM Corporation

Agenda
• Overview • Information and Data Models • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization

4

© 2011 IBM Corporation

Data vs. Information

• Data:

Collection of letters, numbers or facts

• Information: Processed data that provides value

5

© 2011 IBM Corporation

Databases and DBMS • Databases • A repository of data • DBMS (Database management system) • Software system that manages databases • The terms “Database”. “database server” often used interchangeably to refer to a DBMS • Why a DBMS? • Security • Can handle many users with good performance • Allows for concurrency while keeping data consistent • Protects from disaster 6 © 2011 IBM Corporation . “data server”. “DBMS”.

Agenda • Overview • Information and Data Models • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 7 © 2011 IBM Corporation .

Information and Data Models Relationship between an Information Model and a Data Model 8 © 2011 IBM Corporation .

Data Models • Network • Hierarchical • Relational • Entity-Relationship • Extended relational • Semantic • Object-oriented • Object-relational • Semi-structured 9 © 2011 IBM Corporation .

Agenda • Overview • Information and Data Models • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 10 © 2011 IBM Corporation .

Relational Model 11 © 2011 IBM Corporation .

Entity-Relationship Diagrams • Building Blocks • Entities • Attributes Entity Attribute 12 © 2011 IBM Corporation .

Entity and Attributes 13 © 2011 IBM Corporation .

ER diagram Title Description Editon Aisle Book Year Pages ISBN Price 14 © 2011 IBM Corporation .

Exercise: Identify entities and attributes House Social Security Number Product Date Height 15 Phone # Computer Order # © 2011 IBM Corporation .

Did you get them right? House Social Security Number Product Date Height 16 Phone # Computer Order # © 2011 IBM Corporation .

Agenda • Overview • Entity-relationship diagrams • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 17 © 2011 IBM Corporation .

Relationships • Building Blocks – Entity sets – Relationship sets – Crows Foot notations 18 © 2011 IBM Corporation .

ERD of Book Title Description Editon Aisle Book Year Pages ISBN Price 19 © 2011 IBM Corporation .

ERD of Author Author_Id Lastname Country Author Firstname City Email 20 © 2011 IBM Corporation .

Example 1 21 © 2011 IBM Corporation .

Example 2 22 © 2011 IBM Corporation .

Types of Relationships Book Authored By Author One-to-one Relationship 23 © 2011 IBM Corporation .

Types of Relationships (Continued) Book Authored By Author One-to-many Relationships 24 © 2011 IBM Corporation .

Types of Relationships (Continued) Book Authored By Author Many-to-many Relationships 25 © 2011 IBM Corporation .

Agenda • Overview • Entity-relationship diagrams • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 26 © 2011 IBM Corporation .

ERD revisited Title Description Editon Aisle Book Year Pages ISBN Price 27 © 2011 IBM Corporation .

Mapping entity to a table Description Title Editon Entity Book Table Aisle Pages Attributes ISBN Price Year Columns 28 © 2011 IBM Corporation .

Mapping entity to a table (Continued) Table: Book Title Database Fundamentals Edition 1 Year 2010 Price 24.99 ISBN Pages Aisle DBA02 Description Teaches you the fundamentals of databases Teaches you the essentials of DB2 using DB2 ExpressC.99 DBA01 29 © 2011 IBM Corporation . the free version of DB2 978-0.300 98662 83-1-1 978-0.280 98662 83-5-1 Getting started 1 with DB2 Express-C 2010 24.

com City Toronto Toronto Toronto Chennai Country CA CA CA IN Transilva RO nia 30 © 2011 IBM Corporation .Mapping entity to a table (Continued) Table: Author Author_ID A1 A2 A3 A4 A5 Lastname Chong Ahuja Hakes Sharma Perniu Firstname Raul Rav Ian Neeraj Liviu Email rfc@ibm.com lp@univ.com ih@ibm.com ra@ibm.com ns@ibm.

Agenda • Overview • Entity-relationship diagrams • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 31 © 2011 IBM Corporation .

F. Codd of IBM in 1970: “A Relational Model for Large Shared Data Banks” • Building Blocks • Relation • Sets 32 © 2011 IBM Corporation . E.Relational Model Concepts Dr.

A Relational Database • Relational Database • Relation • Relation Schema • Relation Instance 33 © 2011 IBM Corporation .

com ns@ibm.com ih@ibm.com ra@ibm. email: varchar. country: char) Relation Schema Relation Instance DEGREE=6 CARDINALITY=5 Author_ ID Lastname ATTRIBUTES Firstna me Email City Country A1 A2 Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm. lastname: varchar.A Relation AUTHOR(Author_ID: char.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO TUPLES A3 A4 A5 A DOMAIN is the set of all possible values for a specific attribute 34 © 2011 IBM Corporation . firstname: varchar.com lp@univ. city: varchar.

Agenda • Overview • Entity-relationship diagrams • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 35 © 2011 IBM Corporation .

Relational Model Constraints Business Rules Book Authored By Author Referencing Data Integrity 36 © 2011 IBM Corporation .

ERD representation of a Relational Data Model Primary Key Parent Table Dependant Table Foreign Key 37 © 2011 IBM Corporation .

Constraints • Entity Integrity Constraint • Referential Integrity Constraint • Semantic Integrity Constraint • Domain Constraint • Null Constraint • Check Constraint 38 © 2011 IBM Corporation .

com lp@univ.com ns@ibm.Entity Integrity Constraint AUTHOR Author_ID [PK] A1 A2 A3 A4 A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 39 © 2011 IBM Corporation .com ih@ibm.com ra@ibm.

com ih@ibm.Entity Integrity Constraint AUTHOR Author_ID [PK] A1 A2 A3 A4 A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ns@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 40 © 2011 IBM Corporation .com ra@ibm.com lp@univ.

Entity Integrity Constraint AUTHOR Author_ID [PK] A1 NULL A2 A3 A4 A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ih@ibm.com ra@ibm.com ns@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 41 © 2011 IBM Corporation .com lp@univ.

Entity Integrity Constraint AUTHOR Author_ID [PK] A1 NULL A2 A3 A4 NULL A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 42 © 2011 IBM Corporation .com ra@ibm.com ih@ibm.com ns@ibm.com lp@univ.

Referential Integrity Constraint Book Authored By Author Referencing 43 © 2011 IBM Corporation .

com ra@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 44 © 2011 IBM Corporation .Semantic Integrity Constraint AUTHOR Author_ID [PK] A1 A2 A3 A4 A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ns@ibm.com lp@univ.com ih@ibm.

com ns@ibm.Semantic Integrity Constraint AUTHOR Author_ID [PK] A1 A2 A3 A4 A5 Lastname Firstname Email City Country Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ih@ibm.com Toronto 12(*)&^23 Toronto Toronto Chennai Transilvania CA CA CA IN RO 45 © 2011 IBM Corporation .com lp@univ.com ra@ibm.

com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 46 © 2011 IBM Corporation .com ih@ibm.Domain Constraint AUTHOR Author_ID Lastname Firstname Email City Country A1 A2 A3 A4 A5 Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ra@ibm.com lp@univ.com ns@ibm.

com Toronto Toronto Toronto Chennai Transilvania CA 34 CA 34 CA 34 IN RO 47 © 2011 IBM Corporation .com ra@ibm.com ns@ibm.Domain Constraint AUTHOR Author_ID Lastname Firstname Email City Country A1 A2 A3 A4 A5 Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.com ih@ibm.com lp@univ.

com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 48 © 2011 IBM Corporation .com ra@ibm.com ns@ibm.com ih@ibm.com lp@univ.NULL Constraint AUTHOR Author_ID Lastname Firstname Email City Country A1 A2 A3 A4 A5 Chong Ahuja Hakes Sharma Perniu Raul Rav Ian Neeraj Liviu rfc@ibm.

com lp@univ.NULL Constraint AUTHOR Author_ID Lastname Firstname Email City Country A1 A2 A3 A4 A5 Chong Ahuja Hakes NULL Sharma Perniu Raul NULL Rav Ian Neeraj Liviu rfc@ibm.com Toronto Toronto Toronto Chennai Transilvania CA CA CA IN RO 49 © 2011 IBM Corporation .com ra@ibm.com ih@ibm.com ns@ibm.

the free version of DB2 978-0.99 DBA01 50 © 2011 IBM Corporation .Check Constraint BOOK Title Database Fundamentals Edition 1 Year 2010 Price 24.99 ISBN Pages Aisle DBA02 Description Teaches you the fundamentals of databases Teaches you the essentials of DB2 using DB2 ExpressC.280 98662 83-5-1 Getting started 1 with DB2 Express-C 2010 24.300 98662 83-1-1 978-0.

Check Constraint BOOK Title Database Fundamentals Edition 1 Year 2010 Price 24.99 ISBN Pages Aisle DBA02 Description Teaches you the fundamentals of databases Teaches you the essentials of DB2 using DB2 ExpressC.300 98662 83-1-1 978-0.99 2015 DBA01 51 © 2011 IBM Corporation .280 98662 83-5-1 Getting started 1 with DB2 Express-C 2010 24. the free version of DB2 978-0.

Agenda • Overview • Entity-relationship diagrams • The relational model • Entity-Relationship diagrams • Types of relationships • Mapping entities to tables • Relational model concepts • Relational model constraints • Normalization 52 © 2011 IBM Corporation .

Normalization ■ ■ Process in database design to remove redundancies Example: Consider the following table listing all the tasks of an employee: Problem: If John moves to a new city. all entries related to John must be updated 53 © 2011 IBM Corporation .

no loss of information 54 © 2011 IBM Corporation .Normalization (continued) No redundancy. no anomalies.

Thank you! 55 © 2011 IBM Corporation .

Sign up to vote on this title
UsefulNot useful