This document provides an introduction to relational databases and covers key concepts like relational tables, keys, relationships and integrity rules. It explains that tables are the basic building blocks and discusses primary keys, foreign keys and candidate keys. The learning outcomes are to explain the relational model's components, how relations are organized in tables, and how data redundancy is handled.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
32 views26 pages
CT042-3-1-IDB-Week 4
This document provides an introduction to relational databases and covers key concepts like relational tables, keys, relationships and integrity rules. It explains that tables are the basic building blocks and discusses primary keys, foreign keys and candidate keys. The learning outcomes are to explain the relational model's components, how relations are organized in tables, and how data redundancy is handled.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26
Introduction to Databases
CT042-3-1-IDB (version1)
Week 4: Relational Database
(Part 1) Topic & Structure of The Lesson
• Relational table • Relational model components • Data integrity rules • Data dictionary
CT042-3-1-IDB Relational Database Slide 2 of 26
Learning Outcomes
• At the end of this topic, You should be able
to – Explain the relational model’s basic components – Explain how relations are organized in tables – Explain how data redundancy is handled in the relational database model
CT042-3-1-IDB Relational Database Slide 3 of 26
Key Terms You Must Be Able To Use • If you have mastered this topic, you should be able to use the following terms correctly in your assignments and exams: – Primary key – Foreign key – Candidate key – Attribute – domain
CT042-3-1-IDB Relational Database Slide 4 of 26
A Logical View of Data • Relational model – Enables programmer to view data logically rather than physically • Table – Has advantages of structural and data independence – Resembles a file from conceptual point of view – Easier to understand than its hierarchical and network database predecessors
CT042-3-1-IDB Relational Database Slide 5 of 26
Tables and Their Characteristics
• Table: two-dimensional structure
composed of rows and columns • Contains group of related entities = an entity set – Terms entity set and table are often used interchangeably
CT042-3-1-IDB Relational Database Slide 6 of 26
Tables and Their Characteristics (continued) • Table also called a relation because the relational model’s creator, Codd, used the term relation as a synonym for table • Think of a table as a persistent relation: – A relation whose contents can be permanently saved for future use
CT042-3-1-IDB Relational Database Slide 7 of 26
Tables and Their Characteristics (continued)
CT042-3-1-IDB Relational Database Slide 8 of 26
Tables and Their Characteristics (continued)
CT042-3-1-IDB Relational Database Slide 9 of 26
Keys
• Consists of one or more attributes that
determine other attributes • Primary key (PK) is an attribute (or a combination of attributes) that uniquely identifies any given entity (row) • Key’s role is based on determination – If you know the value of attribute A, you can look up (determine) the value of attribute B
CT042-3-1-IDB Relational Database Slide 10 of 26
Keys (continued)
• Foreign key (FK)
– An attribute whose values match primary key values in the related table • Referential integrity – FK contains a value that refers to an existing valid tuple (row) in another relation • Secondary key – Key used strictly for data retrieval purposes
CT042-3-1-IDB Relational Database Slide 11 of 26
Candidate Key
• A Candidate Key can be any column or a
combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.
CT042-3-1-IDB Relational Database Slide 12 of 26
CT042-3-1-IDB Relational Database Slide 13 of 26 How to select Primary Key
• select a key that does not contain NULL
• Select a key that is unique and does not repeat • Make sure that Primary Key does not keep changing
CT042-3-1-IDB Relational Database Slide 14 of 26
Keys (continued) • Nulls: – No data entry – Not permitted in primary key – Should be avoided in other attributes – Can represent • An unknown attribute value • A known, but missing, attribute value • A “not applicable” condition – Can create problems when functions such as COUNT, AVERAGE, and SUM are used – Can create logical problems when relational tables are linked
CT042-3-1-IDB Relational Database Slide 15 of 26
Keys (continued) • Controlled redundancy: – Makes the relational database work – Tables within the database share common attributes that enable the tables to be linked together – Multiple occurrences of values in a table are not redundant when they are required to make the relationship work – Redundancy exists only when there is unnecessary duplication of attribute values CT042-3-1-IDB Relational Database Slide 16 of 26 Keys (continued)
CT042-3-1-IDB Relational Database Slide 17 of 26
Keys (continued)
CT042-3-1-IDB Relational Database Slide 18 of 26
Integrity Rules
CT042-3-1-IDB Relational Database Slide 19 of 26
Integrity Rules (continued)
CT042-3-1-IDB Relational Database Slide 20 of 26
The Data Dictionary and System Catalog • Data dictionary – Provides detailed accounting of all tables found within the user/designer-created database – Contains (at least) all the attribute names and characteristics for each table in the system – Contains metadata—data about data – Sometimes described as “the database designer’s database” because it records the design decisions about tables and their structures
CT042-3-1-IDB Relational Database Slide 21 of 26
A Sample Data Dictionary
CT042-3-1-IDB Relational Database Slide 22 of 26
Quick Review Question • What is a candidate key? • What is a primary key? • What are the criteria for selecting primary key? • What is a foreign key? • What is attribute domain? • What is entity integrity? • What is referential integrity? • Why is NULL not favorable when inserting data values? CT042-3-1-IDB Relational Database Slide 23 of 26 Summary of Main Teaching Points
• Tables are basic building blocks of a relational database
• Keys are central to the use of relational tables • Keys define functional dependencies – Candidate key – Primary key – Secondary key – Foreign key