Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

Chapter 4

Relational
Databases and
Enterprise
Systems

Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
Learning Objectives

• LO#1 Describe the advantages of relational databases.


• LO#2 Explain basic relational database principles.
• LO#3 Describe how to query using Structured Query
Language (SQL).
• LO#4 Understand the purpose and basic framework for an
enterprise system.
• LO#5 Assess how cloud computing facilitates enterprise
systems.

4-2
LO# 1

Introduction of Database

• A database is a collection of related data for various uses.

Three types of data models:

• A Hierarchical data model organizes data into a tree-like


structure that allows repeating information using defined
parent/child relationships.

• A Network data model is a flexible model representing


objects and their relationships.

• A Relational data model is a data model that stores


information in the form of related two-dimensional tables.
4-3
LO# 1

Introduction of Database

• Network data model allows each record to have multiple


parent and child records.

• Relational data model allows designers and users to identify


relationships at the time the database is created or much later
whenever new informational requirements from the data
model are desired.

• While hierarchical and network data models require


relationships to be formed at the database creation, relational
data models can be made up as needed.

4-4
LO# 2

Introduction of Database
• Relational data models are the dominant data model
form in use today likely because they offer many
advantages over other data models, including:

• Flexibility and Scalability: As business and


informational requirements change, relational data
models are able to handle these changes quickly and
easily. For this flexibility, the relational data model for
databases is the most popular data model today. In fact,
most enterprise system packages (e.g., SAP, Oracle,
Microsoft, etc.) use the relational data model as their
foundation.

4-5
LO# 2

Introduction of Database

 Simplicity: A relational data model is a relatively simple


model that is easy to communicate to both database
users and database developers.

 Reduced Information Redundancy: A relational data


model requires each piece of data to be recorded only in
one place eliminating the need for information to be
stored in multiple places in the organization. This also
helps keep the information updated since you only have
to update the information once in one database and can
avoid data inconsistency.

4-6
LO# 2

Definitions for Databases

• Database Management System (DBMS) – The DBMS is


defined as a computer program that creates, modifies and
queries the database. Specifically, the DBMS is designed to
manage a database’s storage and retrieval of information.
• Data Dictionary – The data dictionary describes the data
fields in each database record such as field description, field
length, field type (e.g., alphanumeric, numeric), etc.
• Database Administrator – The person responsible for the
design, implementation, repair and security of a firm’s
database.

4-7
LO# 2

Fundamentals of Relational Databases

Entities and Attributes:


• A class in the relational database model could
be a person, place, thing, transaction, or event
about which information is stored. Classes
could be grouped into resources (R), events
(E), and agents (A) in data modeling.
• Attributes are characteristics, properties, or
adjectives that describe each class.

4-8
LO# 2

Fundamentals of Relational Databases


Three Main Constructs
• Table/Relation: The primary construct, used for data storage
with rows and columns much like a spreadsheet. Each table in
a database represents either a class or a relationship between
classes. Tables need to be properly linked to make a relational
database.
• Column: The columns in a table are called fields that
represent the attributes or characteristics of the class or
relationship.
• Rows: The rows in a table are called records or tuples. The
records represent all the specific data values that are
associated with one instance.
4-9
LO# 2

Fundamentals of Relational Databases


Keys and Relationships
• A primary key is an attribute or combination
of attributes that uniquely identify a specific
row in a table.
• A foreign key in the relational database model
serves as an attribute in one table that is a
primary key in another table. A foreign key
acts to provide a logical relationship, or a link,
between two tables.
4-10
LO# 2

Fundamentals of Relational Databases


Illustration of a Relational Database Using Primary and
Foreign Keys for Gizmos and Gadgets, a Phone Reseller

4-11
LO# 2

Fundamentals of Relational Databases


Illustration of a Relational Database Using Primary and Foreign Keys for
Gizmos and Gadgets, a Phone Reseller

4-12
LO# 2

Fundamentals of Relational Databases

Basic Requirements of Tables


• The Entity Integrity Rule: the primary key of a
table must have data values (cannot be null).
• The Referential Integrity Rule: the data value
for a foreign key must either be null or match
one of the data values that already exist in the
corresponding table.

4-13
LO# 2

Fundamentals of Relational Databases

Basic Requirements of Tables


• Each attribute in a table must have a unique name.
• Values of a specific attribute must be of the same type.
• Each attribute (column) of a record (row) must be single-
valued. This requirement forces us to create a
relationship table for each many-to-many relationship.
• All other non-key attributes in a table must describe a
characteristic of the class (table) identified by the
primary key.

4-14
LO# 2

Microsoft Access to Implement a Relational


Database
Introduction to Microsoft Access
Access is a simple database management system that can be
used to run databases for individuals and small firms.
The Access system is composed of seven objects that are used
to implement relational databases.
----Tables are used to store data which consists of a series of rows
(records) and columns (attributes) connected by relationships
(links between tables).
----Queries are a tool used to retrieve and display data derived
from records stored within the database.
----Forms are utilized by users to enter data into tables and view
existing records.

4-15
LO# 2

Microsoft Access to Implement


a Relational Database
• Reports are used to integrate data from one or more queries
and tables to provide useful information to decision makers.
• Pages, Web-based forms, allow data to be entered into the
database in real time from outside of the database system.
• Macros are defined by users to automate processes like
opening a specific form.
• Access’s code can be altered by the use of modules.

4-16
LO# 2

Microsoft Access to Implement a Relational


Database
• Example of relational database modeling
REA Data Model, Attributes and Multiplicities for Steve’s
Stylin’ Sunglasses’ Sales Process

4-17
LO# 2

Microsoft Access to Implement a Relational


Database
Explanations on the Multiplicities regarding the Sales Event

4-18
LO# 2

Microsoft Access to Implement a Relational


Database
SSS may sell more than one pair of sunglasses to a customer at one time.

Every pair of sunglasses SSS creates is unique and could be sold once only.
Zero means a pair of sunglasses could be designed already but not sold yet.

The shop employs two employees who can act as salespersons. A salesperson
(new) may not handle any sale transaction yet, and at most each salesperson
could handle many sale transactions.

One and only one salesperson greets and assists a customer from the
beginning to the end of the sale transaction.

SSS has repeat customers. Customer data are recorded after the first
purchase.

Each sale involves one and only one customer.


4-19
LO# 2

Microsoft Access to Implement a Relational


Database
Explanations on the Multiplicities regarding the Cash Receipt
Event

4-20
LO# 2

Microsoft Access to Implement a Relational


Database

4-21
LO# 2

Microsoft Access to Implement a Relational


Database
Explanations on the Multiplicities between the Sales and
Cash Receipt Events

4-22
LO# 2

Microsoft Access to Implement a Relational


Database
Step 1. Open Access.
Step 2. Access will ask you to choose from available templates. Select “Blank
database”

4-23
LO# 2
Microsoft Access to Implement a Relational
Database
Step 3. To change the name of the database, click File  Save Database As,
then save the database as ‘SSS.’ You will likely get a message saying “All
objects must be closed before you save the database” . Click “Yes.”

Step 4. Ensure that the ribbon marked “Enable content” is enabled.

4-24
LO# 2

Microsoft Access to Implement a Relational


Database
Creating New Tables in Access
Step 1. Click the tab Create  Table. (Note: The Table Design button will create a
table and open it in Design View.)

4-25
LO# 2

Microsoft Access to Implement a Relational


Database
• Step 2. Click the tab Home  View (dropdown menu)  Design View.

4-26
LO# 2

Microsoft Access to Implement a Relational


Database
Step 3. Save the table as “Customer.” Note the Field Name, Data type,
Description columns. You will use these to configure the Customer table.

4-27
LO# 2

Microsoft Access to Implement a Relational


Database
Step 4. The first attribute of Customer Table will be its primary key. Highlight
ID in the Field Name column and change it to “Customer Number.” You
should see a key icon next to the Customer. If it is not there, right click and
select “Primary Key” or look for the primary key button on the design tab of
the ribbon.

A field name may


contain 64 characters
and may not contain
periods, exclamation
points or brackets
because they are used
in Visual Basic scripts.

4-28
LO# 2

Microsoft Access to Implement a Relational


Database
Step 5. Click on the dropdown button for the Data Type and select Number.
This will force any data entered into this field to be in the form of a number.

Step 6. Set Field Properties for each attribute. For example, for Customer
Number we would set the Field Size to Long Integer, the Validation Rule to ‘Like
“######”.’By doing so, we will ensure that all Customer Numbers are 6
numbers long . Since this is a primary key, choose the Required field as “Yes”
and the Indexed field as “Yes (No Duplicates)”

4-29
LO# 2

Microsoft Access to Implement a Relational


Database
Step 7. For some fields, it is
appropriate to use an Input
Mask. For example,
Customer Zip should have
an Input Mask. To do this,
select the attribute
Customer Zip and click in
the Input Mask area in the
Field Properties box. You
will see to the right a button
with “…” on it. Click this
button to bring up the Input
Mask Wizard. Select Zip
Code from the menu and
click Next and Finish.
4-30
LO# 2

Microsoft Access to Implement a Relational


Database
Step 8. Create the rest of the tables and attributes given before, using
appropriate data types and properties. Generally, validation rules are used
for primary keys. The attributes of the Sales table are as follows. For other
fields such as Sales Date in the Sales table you will also use Input Masks.

4-31
LO# 2

Microsoft Access to Implement a Relational


Database
• Creating Relationships in Access

Step 1. To pull up the Relationship


window, click Database Tools 
Relationships.
Step 2. Click the Show Table button
in the Design tab to pull up a list of
all your tables. Select all your tables
and press the Add button. Arrange
the tables in the form similar to the
data model.
Step 3. Click each primary key that
you want to link and drag it to its
respective foreign key in another
table. Be sure to check the “Enforce
Referential Integrity” box for each
relationship
4-32
LO# 2

Microsoft Access to Implement a Relational


Database
Step 4. When you have completed this process for all relationships among
your tables. You have created a referential database in Access for Steve’s
Stylin’ Sunglasses

4-33
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
• Creating a form for data entry and display
Step1. Open the database of SSS in Microsoft Access.
Step2. Display all the tables on the left-hand side of database window and
highlight the Customer table. Click on the “Form Wizard” icon in the form
section of the Create tab.

4-34
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 3. In the pop-up Form Wizard window, select Customer table from the
Table/Queries pull-down menu, and select all seven fields for inclusion in the
form.

4-35
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 4. Click the “Next” button. You will see four types of form layouts.
Choose “Columnar” as the form layout.

4-36
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 5. Click the “Next” button. Name the title of the form as “Customer
Form” and select “Modify the form’s design”. Click Finish.

4-37
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 6. click design view of the Customer Form in which you can format the
form. The customer zip text field looks too wide. Select the customer zip field
and resize it.

4-38
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 7. Adjust the size of the text field for Customer First Name, Customer
Last Name, Customer City, Customer Address, and Customer Email.

4-39
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 8. In order to enter data using the form, we need to switch to Form View.
Click on the “Form View” icon in the View section of the File tab.

4-40
LO# 2

Microsoft Access to Implement a Relational


Database (Form)
Step 9. In the Form View, enter a new customer record. If you would like to
add the second record using this form, click on the triangle symbol icon on
the record line at the bottom of the Customer Form.

Step 10. Close and save the Customer Form. Double click on the Customer
Table on the left-hand of the database window to open the table. You will see
the new record has already been entered into the Customer Table.

Step 11. Save and close the SSS file.

4-41
LO# 2

Microsoft Access to Implement a Relational


Database (Form)

4-42
LO# 3

Structured Query Language (SQL)


• SQL (usually pronounced "Sequel") stands for Structured
Query Language and is a computer language designed to
query data in a relational database.
• SQL is based on relational algebra and allows a user to query
and update the database.
• In a database, while queries allow the user to access, read and
report on desired data, the responsibility of actually making
physical changes to the relational database belongs to the
Database Management System (DBMS).

4-43
LO# 3

Structured Query Language (SQL)

• The SELECT statement is used to begin a query.

• The SELECT statement tells the query which columns


(or attributes) of a table should be included in the
query.

• The FROM clause to the SELECT statement indicates


the name of table(s) from which to retrieve data.

4-44
LO# 3

Structured Query Language (SQL)


SQL Example #1: Given the attributes in the Customer table,
how to use a query to find the salesperson for each
customer?

4-45
LO# 3

Structured Query Language (SQL)


• SQL Example #1: how to use a query to find the salesperson
for each customer?
SELECT Customer #, Name, SP#
FROM Customer;
We will get the following query result:

4-46
LO# 3

Structured Query Language (SQL)


The WHERE clause states the criteria that must be met to be
shown in the query result.

SQL Example #2: how to retrieve all cash receipt information


for customer C-2 from the “Cash Receipt” table .

4-47
LO# 3

Structured Query Language (SQL)


SELECT *
FROM [Cash Receipt]
WHERE [Customer Number] = ’C-2’
We will get the following query result:

4-48
LO# 3

Structured Query Language (SQL)


• SQL Example #3: Assume you would like to use a query to find
the salesperson for each customer, and you would like to
show the name of each salesperson as part of the result.

4-49
LO# 3

Structured Query Language (SQL)


SELECT Customer#, Name, SP#, SP_Name
FROM Customer, Salesperson
WHERE Customer.SP#=Salesperon. SP#;

We will get the following query result:

4-50
LO# 3

Structured Query Language (SQL)


The GROUP BY operator is used with aggregate
functions on the query results based on one or more
columns.

SQL Example #4: Refer to the Cash Receipt table in SQL


Example #2. Assume you would like to know the total
cash receipt amount from each customer. If you use the
following SQL command, you can get the result.

4-51
LO# 3

Structured Query Language (SQL)


SELECT [Customer Number], SUM(Amount)
FROM [Cash Receipt]
GROUP BY [Customer Number];

We will get the following query result:

Customer Number Amount

C-2 13,335

C-1 72,000

C-5 32,600

4-52
LO# 3

Structured Query Language (SQL)


The ORDER BY clause identifies which columns are used
to sort the resulting data. If there is no ORDER BY
clause, the order of rows returned by an SQL query will
not be defined.

SQL Example #5: Refer to the Cash Receipt table in SQL


Example #2., if we use the following SQL commands
instead, the amount of cash receipt would be ordered in
ascending amount (ASC) or descending amount (DESC).
The result is different from that of Example #2.

4-53
LO# 3

Structured Query Language (SQL)


SELECT *
FROM [Cash Receipt]
WHERE [Customer Number] = ‘C-2’
ORDER BY Amount ASC;

We will get the following query result:

Remittance Bank Customer Cashier


Advice# Amount Account# Date Number Number

RA-1 1,666 BA-6 25-JUL-2014 C-2 E-39

RA-5 1,669 BA-6 25-AUG-2014 C-2 E-39

RA-2 10,000 BA-7 26-JUL-2014 C-2 E-39

4-54
LO# 3

Structured Query Language (SQL)


• The INSERT INTO operator inserts data into a SQL
table.
• The UPDATE operator is for updating data in a SQL
table.
• The DELETE FROM operator deletes data from a SQL
table.
• SELECT DISTINCT clause selects a column without
showing repetitive values.
• The BETWEEN operator can be used to specify the
end points of a range.
• Membership Operator (IN) allows you to test
whether a data value matches the specified target
values.
4-55
LO# 3

Structured Query Language (SQL)

Six relational operators in SQL:


Relational Operators Meaning
• = equal
• != or <> not equal
• < less than
• <= less than or equal to
• > greater than
• >= greater than or equal to

4-56
LO# 3

Structured Query Language (SQL)

SQL language provides several convenient aggregate functions to


be used in SQL commands. These aggregate functions include
AVG, SUM, MAX, MIN, and COUNT. Their definitions are as
follows:
• AVG(X): gives the average of column X.
• SUM(X): gives the summation of all rows that satisfy the
selection criteria for column X.
• MAX(X): gives the maximum value of column X.
• MIN(X): gives the minimum value of column X.
• COUNT(X): gives the number of rows that satisfy the given
condition.

4-57
LO# 4

Enterprise Systems
Enterprise systems (ES), also known as Enterprise
Resource Planning (ERP) systems, are commercialized
information systems that integrate and automate business
processes across a firm’s value chain located within and
across organizations. Typically, an enterprise system uses
relational data model as a basis for the information
system. The use of primary and foreign keys links the
hundreds of tables that form the basis for the enterprise
system.

In fact, for a popular ERP product (SAP/ERP) installation, there


are 10,000 tables that are all linked to each other!

4-58
LO# 4

Enterprise Systems
• ES accommodates the integration and support of the various
business processes and information needs of a company.
• ES has a higher level of internal transparency compared to the
typically isolated legacy systems.
• The purported informational benefits of an enterprise system
include enhanced completeness, transparency, and timeliness
of information needed to manage effectively an organization’s
business activities.
• The enterprise system serves as the backbone of the
company’s internal business processes and serves as a
connection with the external business processes for supply
chain and customer relationship management systems.

4-59
LO# 4

Enterprise Systems
Challenges of Enterprise System Implementation
• integrating various modules within the enterprise system,
• integrating with external systems such as the information
system of a supplier and/or customer,
• integrating with the firm’s own existing legacy systems,
• converting data from existing legacy systems to the enterprise
system, and
• getting any big project implemented at a firm.

4-60
LO# 5

Enterprise Systems

Enterprise Systems Computing in a Cloud


• In recent years, cloud computing has emerged as a potential
alternative to host enterprise systems and other firm
computing needs.
• Cloud computing is Internet-based computing where shared
resources, software, and information are provided to firms on
demand.
• Cloud Computing can easily host enterprise system
applications.
• Cloud computing, of course, has disadvantages as well.
Ensuring that any sensitive data is secure and backed up
frequently by the host is often a concern of cloud computing
clients.
4-61
Questions

4-62

You might also like