0% found this document useful (0 votes)
7 views24 pages

Chapter 2 Dbms

Uploaded by

sekeriyeaxmed566
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views24 pages

Chapter 2 Dbms

Uploaded by

sekeriyeaxmed566
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Chapter 2

The Relational Database Model


A Logical View of Data
 The relational model organizes data into
tables (relations) made of rows (tuples) and
columns (attributes). Each table has a
unique key (primary key) and can relate to
others through foreign keys.
 Table
 A table is a collection of data in rows
(records) and columns (attributes) in a
database. Easier to understand

Database Systems 6e/Rob & Coronel 3-2


Tables and Their Characteristics

 Table: two-dimensional structure composed of


rows and columns

 A table is a group of related items, called an


entity set, which holds entities (or records) of
the same type. The terms "entity set" and
"table" are often used interchangeably.

Database Systems 6e/Rob & Coronel 3-3


Characteristics of a Relational Table

Table 3.1

Database Systems 6e/Rob & Coronel 3-4


STUDENT Table Attribute Values

Database Systems 6e/Rob & Coronel 3-5


Keys
 Consists of one or more attributes that determine
other attributes
 Each row in a table must be uniquely identifiable
 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. This is written as AB
(A determines B)

Database Systems 6e/Rob & Coronel 3-6


Determination
 Determination is when one attribute
uniquely identifies another, like a primary
key defining other fields in a record.
 Knowing STU_ID in the STUDENT table
means you are able to look up (determine) the
student’s last name, GPA, phone number, etc.
 STU_IDSTU_LNAME
 STU_IDSTU_LNAME, STU_FNAME,
STU_INIT,STU_DOB,STU_TRANSFER

Database Systems 6e/Rob & Coronel 3-7


Keys
 Composite key
 Composed of more than one attribute

 Key attribute
 Any attribute that is part of a key.

Database Systems 6e/Rob & Coronel 3-8


Keys
 Superkey
 Any key that uniquely identifies each entity

 Candidate key
 A superkey without redundancies

Database Systems 6e/Rob & Coronel 3-9


Null Values
 No data entry (zero or space values are not null)
 Primary keys cannot have empty (null) values to keep
each record unique and ensure data integrity.
 Can create problems when functions such as
COUNT, AVERAGE, and SUM are used
 Can create logical problems when relational tables
are linked
 Can represent
 An unknown attribute value
 A known, but missing, attribute value

Database Systems 6e/Rob & Coronel 3-10


Controlled Redundancy
 Makes the relational database work
 Tables within the database share common attributes that
enable us to link tables together
 Redundancy is unnecessary duplication of data

3-11
An Example of a
Simple Relational Database

Database Systems 6e/Rob & Coronel 3-12


The Relational Schema for the
CH03_SaleCo Database

Database Systems 6e/Rob & Coronel 3-13


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 (Alternate key)
 Key used strictly for data retrieval purposes

Database Systems 6e/Rob & Coronel 3-14


Relational Database Keys

Database Systems 6e/Rob & Coronel 3-15


Relational Database Operators
 Relational algebra
 Defines theoretical way of manipulating table
contents using relational operators:
 SELECT  UNION
 INTERSECT
 DIFFERENCE

 Use of relational algebra operators on existing


tables (relations) produces new relations

Database Systems 6e/Rob & Coronel 3-16


Relational Algebra Operators
 Union:
 Combines all rows from two tables, excluding
duplicate rows
 Tables must have the same attribute
characteristics
 Intersect:
 Yields only the rows that appear in both
tables

Database Systems 6e/Rob & Coronel 3-17


Union

Database Systems 6e/Rob & Coronel 3-18


Intersect

Database Systems 6e/Rob & Coronel 3-19


Relational Algebra Operators
 Difference
 Yields all rows in one table not found in the
other table—that is, it subtracts one table
from the other

Database Systems 6e/Rob & Coronel 3-20


Difference

Database Systems 6e/Rob & Coronel 3-21


Relational Algebra Operators
 Select
 Yields values for all rows found in a table
 Can be used to list either all row values or it
can yield only those row values that match a
specified criterion
 Yields a horizontal subset of a table

Database Systems 6e/Rob & Coronel 3-22


Select

Database Systems 6e/Rob & Coronel 3-23


The end

Database Systems 6e/Rob & Coronel 3-24

You might also like