Week 2
Week 2
Week 2
Chapter 2
Database Models
Learning Objectives
After completing this chapter, you will be able to:
Discuss data modeling and why data models are important
Describe the basic data-modeling building blocks
Define what business rules are and how they influence database design
Understand how the major data models evolved
List emerging alternative data models and the needs they fulfill
Explain how data models can be classified by their level of abstraction
Data Modeling & Data Models
Entity: person, place, thing, or event about which data will be collected
and stored
– Attribute: characteristic of an entity
– Relationship: association among entities
■ One-to-many (1:M OR 1..*)
■ Many-to-many (M:N or *..*)
■ One-to-one (1:1 OR 1..1)
– Constraint: restriction placed on data
■ Ensures data integrity
Business Rules
Company
managers
Reasons for identifying and
Policy makers documenting business rules
Department
managers Assist designers
• Understand the nature, role,
Facilitate
scope of data, and business
Standardize company’s communications tool
Written processes
view of data between users and • Develop appropriate
documentation
designers relationship participation rules
and constraints
Direct • Create an accurate data model
interviews with
end users
Translating Business Rules into
Data Model Components
Proper naming
• Emerged with the network model are still used by modern data
models
Standard database • Schema and subschema
concepts • Data manipulation language (DML)
• Data definition language (DDL)
The Relational Model (1 of 3)
Model
• Performs basic functions provided by the
Relational hierarchical and network DBMS systems
• Makes the relational data model easier to
database understand and implement
management • Hides the complexities of the relational
model from the user
system (RDBMS)
Produced an automatic • Based on a relation (i.e., table):
matrix composed of intersecting
transmission database tuples (rows) and attributes
that replaced standard (columns)
transmission databases
The Relational Model (2 of 3)
The Relational Model (3 of 3)
SQL-based relational database application:
End-user interface
• Allows end user to interact with the data
SQL engine
• Executes all queries
The Entity Relationship Model
Graphical representation of entities and their relationships in a database
structure
Attributes Connectivity
OLAP tools
Volume doesn’t proved
allow usage of inconsistent
Challenges conventional
Expensive
dealing with
structures unstructured
data
New Hadoop
Hadoop
Distributed File MapReduce NoSQL
technologies System (HDFS)
Emerging Data Models: NoSQL
■ NoSQL databases
– Not based on the relational model
– Support distributed database architectures
– Provide high scalability, high availability, and fault tolerance
– Support large amounts of sparse data
– Geared toward performance rather than transaction consistency
– Provides a broad umbrella for data storage and manipulation
Discussion: ■ Hierarchical Model
■ Network Model
Disadvantag ■ NoSQL
es
End users’
People who use the
view of the application programs to
manipulate the data and
data
environment
generate information
The
ER
External
diagrams
are used to
External schema:
specific
Model
representation of an
represent external view
the external
views
The Conceptual Model
Physical Low Storage and access methods Neither hardware nor software
Summary
■ Determination
– State in which knowing the value of one attribute makes it possible
to determine the value of another
■ Establishes the role of a key
■ Based on the relationships among the attributes
■ Functional dependence: value of one or more attributes determines the
value of one or more other attributes
– Determinant: attribute whose value determines another
– Dependent: attribute whose value is determined by the other
attribute
■ Full functional dependence: entire collection of attributes in the
determinant is necessary for the relationship
Types of Keys (1 of 3)
■ Relational database integrity rules are very important to good database design
– Relational database management systems (RDBMSs) enforce integrity rules
automatically
■ Much safer to make sure the application design conforms to entity and
referential integrity rules
Entity Integrity
• Requirement
• All primary key entries are unique, and no part of a primary key may be null.
• Purpose
• Each row will have a unique identity, and foreign key values can properly reference primary key
values.
• Example
• No invoice can have a duplicate number, nor can it be null; in short, all invoices are uniquely
identified by their invoice#.
Referential Integrity
• Requirement
• A foreign key may have either a null entry, as long as it is not a part of its table’s primary key, or
an entry that matches the primary key value in a table to which it is related (every non-null
foreign key value must reference an existing primary key value).
• Purpose
• It is possible for an attribute not to have a corresponding value, but it will be impossible to have
an invalid entry; the enforcement of the referential integrity rule makes it impossible to delete a
row in one table whose primary key has mandatory matching foreign key values in another table.
• Example
• A customer might not yet have an assigned sales representative (number), but it will be
impossible to have an invalid sales representative (number).
Relational Algebra
■ Theoretical way of manipulating table contents using relational operators
– Relvar: variable that holds a relation
■ Heading contains the names of the attributes
■ Body contains the relation
– Relational operators have the property of closure
■ Closure: use of relational algebra operators on existing relations produces new relations
Relational Set Operators (1 of
10)
■ Select (restrict)
– Unary operator that yields a horizontal subset of a table
■ Project
– Unary operator that yields a vertical subset of a table
■ Union
– Combines all rows from two tables, excluding duplicate rows
– Union-compatible: tables share the same number of columns, and their
corresponding columns share compatible domains
■ Intersect
– Yields only the rows that appear in both tables
– Tables must be union-compatible to yield valid results
Relational Set Operators (2 of
10)
Relational Set Operators (3 of
10)
Relational Set Operators (4 of
10)
Relational Set Operators (5 of
10)
■ Difference
– Yields all rows in one table that are not found in the other table
– Tables must be union-compatible to yield valid results
Relational Set Operators (6 of
10)
■ Product: Yields all possible pairs of rows from two tables
Relational Set Operators (7 of 10)
■ Divide
– Uses one double-column table as the dividend and one single-column table
as the divisor
– Output is a single column that contains all values from the second column
of the dividend that are associated with every row in the divisor
Relational Set Operators (10 of
10)
Data Dictionary and the System
Catalog
■ Data dictionary
– Description of all tables in the database created by the user and
designer
■ System catalog
– System data dictionary that describes all objects within the database
■ Homonyms and synonyms must be avoided to lessen confusion
– Homonym: same name is used to label different attributes
– Synonym: different names are used to describe the same attribute
Relationships within the Relational Database
■ One-to-many (1:M)
– Norm for relational databases
■ One-to-one (1:1)
– One entity can be related to only one other entity and vice versa
■ Many-to-many (M:N)
– Implemented by creating a new entity in 1:M relationships with the
original entities
– Composite entity (i.e., bridge or associative entity): helps avoid
problems inherent to M:N relationships
■ Includes the primary keys of tables to be linked
Data Redundancy (Revisited)
■ The relational database facilitates control of data redundancies through use of
foreign keys
– Common attributes that are shared by tables
■ To be controlled except the following circumstances:
– Sometimes data redundancy must be increased to make the database serve
crucial information purposes
– Sometimes data redundancy exists to preserve the historical accuracy of data
Indexes