Relational Databases Final
Relational Databases Final
AND ENTERPRISE
SYSTEMS
SALES TABLE
Invoice No. Customer ID Date Product No.
Primary Key
Foreign Key
SALES TABLE
Invoice No. Customer ID Date Product No.
Primary Key
PRODUCT TABLE
Product No. Product Name Product Price
Total 399.00
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.
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.
Microsoft Access to Implement a
Relational Database
Microsoft access is a program
in the Microsoft Office Suite.
Access is a simple database
management system that can
be used to run databases for
individuals and small firms.
The basic building block of a
database is the table. It is linked
by the foreign keys, forming an
interconnected network of
records that taken together are
relational database.
Microsoft Access to
Implement a Relational
Database
(1..*)
(1..1)
(1..1)
(1..1)
(1..*)
(0..*)
(1..1)
SALES EVENT
(1..*)
(1..1)
CASH RECEIPT EVENT
(1..1)
(1..*)
(1..1) (0..*)
(0..*)
(1..1)
SALES AND CASH RECEIPT EVENT
(1..1) (1..*)
Assume the following to implement a simple database
using Access.
Customer Sales Person
a)Customer Number a)Salesperson Number
e)Customer Address
Sales
f)Customer City
a)Sale Number
g)Customer email
b)Sale Date
Cashier c)Sale Amount
a)Cashier Number d)Payment type
b)Cashier First Name e)Customer Number
c)Cashier Last Name f)Salesperson Number
d)Cashier SSN
Assume the following to implement a simple database
using Access.
How to query for the total cash receipt from each customer?
Example: GROUP BY
C-5 32,600
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.
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 SQL
table.
SELECT DISTINCT clause selects a column without
showing repetitive values.
Example: ORDER BY
C-1
C-5
Structured Query Language (SQL)
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.
Example: BETWEEN
Used the following SQL command:
SELECT *
FROM Cash Receipt
WHERE Date BETWEEN ’01-JULY-2014’ AND ‘31-JULY-2014’;
Customer
Number
Amount How to query the total cash receipt
C-1 72,000
amount from customer C-1 and C-2?
C-2 13,335
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 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.
Example: MEMBERSHIP OPERATOR (IN)
Used the following SQL command:
SELECT Customer Number , SUM(Amount)
FROM Cash Receipt
WHERE Customer Number IN (‘C-1’, ‘C-2’)
GROUP BY Customer Number
Customer Amount
Number
C-2 72,000
C-2 13,335
Six relational operators in SQL
RELATIONAL OPERATORS MEANING
1. = Equal
2. != or < > Not equal
3. < Less than
4. <= Less than or equal to
5. > Greater than
6. >= Greater than or equal to
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.
Enterprise Systems
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.
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.
Enterprise 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.
Challenges of
Enterprise System
Implementation
Answers: Answers:
1. B 6. A
2. A 7. D
3. C 8. A
4. B 9. C
5. D 10. B