• No results found

Relational Databases. Chapter 4. Copyright 2015 Pearson Education, Inc. 4-1

N/A
N/A
Protected

Academic year: 2021

Share "Relational Databases. Chapter 4. Copyright 2015 Pearson Education, Inc. 4-1"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)

Copyright © 2015 Pearson Education, Inc.

Relational Databases

Chapter 4

(2)

Copyright © 2015 Pearson Education, Inc.

Learning Objectives

• Explain the importance and advantages of databases, as well as the difference between database and file-based legacy systems.

• Explain the difference between logical and physical views of a database.

• Explain fundamental concepts of database systems such as DBMS, schemas, the data dictionary, and DBMS languages.

• Describe what a relational database is and how it organizes data.

• Create a set of well-structured tables to properly store data in a relational database.

• Perform simple queries using the Microsoft Access database.

4-2

(3)

Copyright © 2015 Pearson Education, Inc.

Introduction

Relational databases underlie most modern

integrated AISs.

• They are the most popular type of database used

for transaction processing.

• In this chapter, we’ll define the concept of a

database with the emphasis on understanding the relational database structure

(4)

Copyright © 2015 Pearson Education, Inc.

What Is a Database?

A set of interrelated, centrally coordinated

data files that are stored with as little data

redundancy as possible.

This Figure explain how data are stored in computer systems: 4-3 ًادج هليلق تانايبلا راركت هيناكمإ

(5)

Copyright © 2015 Pearson Education, Inc.

What Is a Database?

A file is a related group of records A record is a related group of fields

A field is a specific attribute of interest for the entity (record)

(6)

Copyright © 2015 Pearson Education, Inc.

File-Oriented System VS. Database

system

Databases were

developed to address the reproduction of master files. For many years, companies created new files and programs each

time a need for

information arose.

(7)

Copyright © 2015 Pearson Education, Inc.

File-Oriented System VS. Database

system

• In the database approach, data is used by and managed for the entire organization, not just department which produce the data.

A database management system (DBMS) is the program that manages and controls the data and the interfaces between the data and the application programs that use the data stored in the database.

• The database, the DBMS, and the application programs that access the database through the DBMS are referred to as the database system.

(8)

Copyright © 2015 Pearson Education, Inc.

Data Warehouses

Since strategic decision making requires access to large amounts of historical data, organizations are building separate databases called data warehouses.

Data warehouse is a very large databases containing detailed and summarized data for a number of years that are used for analysis rather than transaction processing.

Data warehouses do not replace transaction processing databases; they complement them by providing support for strategic decision making.

Data warehouses are purposely redundant to maximize query efficiency. ملاعتسلاا ةءافك ةدايزل دمع نع ةدئاز

(9)

Copyright © 2015 Pearson Education, Inc.

Business Intelligence.

• Analyzing large amounts of data for strategic

decision making is often referred to as

business intelligence.

• Data warehouses are used for business

intelligence.

• There are two main techniques used in business

intelligence: online analytical processing

(10)

Copyright © 2015 Pearson Education, Inc.

Advantages of Databases

• Data integration.

▫ Achieved by combining master files into larger pools of data accessible by many programs.

• Data sharing.

• Minimize data redundancy and data inconsistencies.

• Data is independent.

▫ Data and the programs that use the data are independent of each other.

• Data is easily accessed for reporting and cross-functional analysis.

(11)

Copyright © 2015 Pearson Education, Inc.

Database System: Views

• The database approach provides two separate views of the data: the physical view and the logical view.

Logical views is how the user or programmer

conceptually organizes and understands the data. (an external level of the database)

Physical view is how and where the data are physically

arranged and stored in the computer system. (an internal level of the database)

• Designers of a database need to understand user’s needs and the conceptual level of the entire database as well as the physical view.

(12)
(13)

Copyright © 2015 Pearson Education, Inc.

Benefit of Separating Physical &

Logical views of data

• Allows the user to access, query, and update data without reference to how or where it is physically stored.

• Users can change their conceptualizations of the data relationships without making changes in the physical storage.

• The database administrator can also change the physical storage of the data without affecting users or application programs.

(14)

Copyright © 2015 Pearson Education, Inc.

Database System:

Schemas

A schema is a description of the data elements

in a database, the relationships among them, and the logical model used to organize and describe the data.

• There are three levels of schemas: the

(15)

Copyright © 2015 Pearson Education, Inc.

Database System:

Schemas

The conceptual-level schema is the organization-wide

view of the entire database

▫ lists all data elements and the relationships among

them.

The external-level schema is an individual user’s view

of portions of a database,

▫ each of which is referred to as a subschema.

The internal-level schema, a low-level view of the

database,

(16)
(17)

Copyright © 2015 Pearson Education, Inc.

Database System: The Data dictionary

• The data dictionary is a “blueprint” of the

structure of the database and includes data elements, field types, programs that use the data element, outputs, and so on. ( refer to table 4-1)

(18)
(19)

Copyright © 2015 Pearson Education, Inc.

Database System: DBMS Languages

• Data Definition Language (DDL)

▫ Builds the data dictionary and creates the database. ▫ Describes logical views for each user Specifies record or

field security constraints

• Data Manipulation Language (DML)

▫ Changes the content in the database Creates, updates, insertions, and deletions

• Data Query Language (DQL)

▫ Enables users to retrieve, sort, and display specific data from the database

• A report writer simplifies report creation.

(20)

Copyright © 2015 Pearson Education, Inc.

Relational Database

• Relational data model represents the conceptual and external schema as if that “data view” were truly stored in one table.

• Although the conceptual view appears to the user that this data is in one big table, it actually stored as described in the internal-level schema.

(21)

Copyright © 2015 Pearson Education, Inc.

Conceptual View Example

Customer Name Sales Invoice # Invoice Total

D. Ainge 101 $1,447 G. Kite 102 $4,394 D. Ainge 103 $ 898 G. Kite 104 $ 789 F. Roberts 105 $3,994 4-9

(22)

Copyright © 2015 Pearson Education, Inc.

Relational Data Tables

(23)

Copyright © 2015 Pearson Education, Inc.

Relational Data Tables

4-11

Foreign Key (Customer # is a Foreign key in the Sales Table because it is a Primary key that uniquely identifies Customers in the Customer Table). Because of this, the Sales Table can relate to the Customer Table (see red arrow above).

A primary key is the database attribute, or combination of

attributes, that uniquely identifies a specific row in a table.

(24)

Copyright © 2015 Pearson Education, Inc.

Why Have a Set of Related Tables?

• Data stored in one large table can be redundant and inefficient causing the following problems:

▫ Update anomaly

▫ Insert anomaly

▫ Delete anomaly

(25)

Copyright © 2015 Pearson Education, Inc.

Relational Database Design Rules

• Every column in a row must be single valued

• Primary key cannot be null (empty) also known

as entity integrity rule

• Foreign key must either be null or have a value

that corresponds to the value of a primary key in another table (referential integrity rule)

• All other (non-key) attributes in the table must

describe characteristics of the object identified by the primary key

(26)

Copyright © 2015 Pearson Education, Inc.

Relational Database Design Rules

Following the previous four rules allows databases to be normalized and solve the update, insert, and delete anomalies.

For example: Deletion of a class for a student would cause the elimination of one record in the student x class table.

• The student still exists in the student table. • The class still exists in the class table.

• Avoid the delete anomaly.

(27)

Copyright © 2015 Pearson Education, Inc.

Two Approaches To Database Design

There are two approaches to design well- structured relational databases. One is called normalization, and the other is semantic data modeling.

Normalization

(28)

Copyright © 2015 Pearson Education, Inc.

Normalization Approach

• Starts with the assumption that everything is

initially stored in one large table.

• A set of rules is followed to decompose that

initial table into a set of normalized tables.

• Objective is to produce a set of tables in

third-normal form (3NF) because such tables are free of update, insert, and delete anomalies.

(29)

Copyright © 2015 Pearson Education, Inc.

Semantic data modeling Approach

• Database designer uses knowledge about how

business processes typically work and the information needs associated with transaction processing to draw a graphical picture of what should be included in the database.

• The resulting graphic is used to create a set of

relational tables that are in 3NF.

(30)

Copyright © 2015 Pearson Education, Inc.

Creating Relational Database

Queries

• Users may want specific information found in a relational database and not have to sort through all the files to get that information. So they query (ask a question) the data.

• An example of a query might be: What are the invoices of customer D. Ainge and who was the salesperson for those invoices?

(31)

Copyright © 2015 Pearson Education, Inc.

Creating the Query

4-16

(32)

Copyright © 2015 Pearson Education, Inc.

Query Answer

References

Related documents

Just as business query and reporting tools allow users to retrieve data from relational databases without knowing SQL, OLAP viewers allow users to access data in an OLAP

4 ANALIZA STORITEV SLOVENSKIH PODPORNIH INSTITUCIJ ZA VSTOP PODJETIJ NA TUJI TRG 4.1 Finančne storitve Institucije v Sloveniji, ki so specializirane za pomoč podjetjem pri

  We’ve learned how to make a picture for quantitative data to help us see the story the data have to Tell.   We can display the distribution of quantitative data

Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings.. About this Chapter About

Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings.. About this Chapter About

Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings.. About this Chapter About

Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings... Copyright © 2004

Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings Copyright © 2004 Pearson Education, Inc., publishing as Benjamin Cummings.. About this Chapter About