Chapter Four
Relational Databases
1
Traditional file
is stores and process data in traditional file,
which means that these data were stored in a plain
text.
Individual user within the organization own an
independent file
Individual user of functional area in the
organization can create and process its own file.
2
atomicity: if that either all statement ( insert,
update , delate) in side a transaction are either
completed or all of them are rolled back.
Every transaction must follow atomicity property,
which means that if a transaction is started it
should be either completed or rolled.
Consistency: this ensures the data base is in
consistent state before the transaction started and
also left the data in consistent state after the
transaction is completed
Each transaction must transform the data base
from one consistent state to other consistent state.
3
isolation: when multiple transaction are
executed together, none of the transaction should
be effected by the other transaction.
Every transaction should be isolated with each
other, there should not be any interference
between two transaction.
4
Disadvantage of traditional file
Program data dependence
Limited data sharing
Data redundancy and inconsistency
Need too much data storage capacity and cost
Security problem
Problem recovery and atomicity
5
database
Is a set of inter-related centrally coordinated file
Is answer to limitation manifested by traditional
filing approach.
A database that represent data as ac collection of
entity and relationships is relational data
6
Database management system(DBMS)
A Soft ware system that is used to create,
manipulate, maintain organizational data and
provides controlled access to user the data base.
Responsibility of DBMS
a. Data definition
b. Data manipulation
c. Query execution
d. Data integrity
e. Data security
f. Provide data evidence
g. Concurrency
7
Structure query language(SQL)
1. Data definition language(DDL): use to
Build data directory
Initialize or create the data base
Describe the logical view for each user or
programmer.
Specify any limitation or constraints on security
imposed on data base record of field
2. Data manipulation language( DML): use to
Such as updating, inserting and delating portion of
data base.
3. Data query language(DQL): used to
interrogate( examine) the data base.
save record, categories record, order record and
peresent subset of the database in response to user8
Data base management system(DBMS)
Request
DATA
IS DBMS
User BASE
Response
That users should only be able to communicate in
database through an IS
The information system request data from the
database through DBMS and will respond to the
requested data by the IS.
9
cost and risk in implementing DBMS
New specialized personnel
Installation and management cost and complexity
Conversion cost
Need for explicitly backup and recovery
Organizational conflict
10
Advantage of data base
1. Program data independency
2. Planed data redundancy
3. Improve data consistency
4. Increased productively of application
development
5. Improved data sharing
6. Enforcement of standards
7. Improved data accessibility and responsiveness
8. Reduced program maintenance
9. Improve decision support
11
DATABASES The person
Database
Fact A Fact B responsible for the
Fact C Fact D
Fact E Fact F database is the
database
administrator.
Database As technology
Management
System improves, many
large companies
are developing very
Enrollment
Program
Financial Aid
Program
Grades
Program large databases
called data
warehouses.
Logical and Physical Views of
Data
Database systems separate the logical and
physical views of data.
Logical view of data refers to how the user or
programmer conceptually organize and
understand the data.
Example, a sales manager may conceptualize
all information about customers as being
stored in the form of a table.
Physical view of data refers to how and where
the data are physically arranged and stored on
disk, tape, CD ROM, or other media. 13
Schemas
Schema (diagram) describes the logical
structure of a database.
There are three levels of schemas:
Conceptual level schema,
External level schema, and
Internal level schema
conceptual level schema is the
organization-wide view of the entire
database.
It lists all data elements and the
relationships between them. 14
Cont’d……….
External level schema consists of a set of
individual user views of portions of the
database, each of which is also referred to
as a sub-schema.
Internal level schema provides a low-level
view of the database.
It describes how the data are actually
stored and accessed, including
information.
15
Smith . . . A
Jones . . . B
Arnold . . .D
Mapping external-level views to conceptual-level schema
Classes Enroll Student
Cash
Receipt
Mapping conceptual-level items to internal-level descriptions
Student Record Class Record
Student No. --character [9] Class Name --character [9]
Student Name --character [26] Dept No. --integer [4], non-null, index=itemx
SAT Score --integer [2], non-null, index=itemx Course No. --integer [4], non-null, index=itemx
16
Data Dictionary
A key component of a DBMS is the data
dictionary, contains information about
structure of the database.
For each data element stored in the
database, such as the customer number,
there is a corresponding record in the data
dictionary describing it.
One of the first applications of a newly
implemented database system.
Inputs to the data directory include records
of new or deleted data elements, changes in
names, descriptions, or uses of existing data
17
RELATIONAL DATABASES
• The relational data model represents
everything in the database as being stored in
the forms of tables (aka, relations).
TERMINOLOGES
Relational model: represent data as collection
of table.
Relation: a table name
Tuple: each row
Column headers: attributes
Domain: A set of atomic value allowed for an
attributes
Relation schema: describe a relation
Degree of relation: number of attribute in
relation schema
Cardinality: total number of tuples represent
19
Characteristic of relation
Ordering of tuple with in a relation is not
important
-A relation is a set of tuple and tuple in a
relation need not to have particular order
Ordering of value with in tuple is not
important
- An n-tuple: ordered list of a value, so ordering
of value in a tuple is important
- With an alternative definition of relation,
ordering value in tuple is not unnecessary.
- A tuple : set of attribute, value pair, then
20
ordering of attribute is not important
Characteristic of relation
Value and null in tuple: each value in tuple
an atomic value
- Atomic value: multiple value, attribute divided
in different and it need separate table.
- Null: use unknown or not applicable, use
when the value are not unknown, or not
applicable
Interpretation of a relation
- The relation schema can be represented as a
declaration or assertion
- Each tuple can be interpreted as a fact.
21
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
Relation
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID Student ID Course
333333333-1234 333-33-3333 1234
333333333-1236 333-33-3333 1236
111111111-1235 111-11-1111 1235
111111111-1236 111-11-1111 1235
Cont’d………
Relational database tables have three types
of attributes (elements/characteristics):
Primary key
Foreign key
Other non-key attributes
Primary key is the attribute or combination
of attributes that uniquely identifies a specific
row in a table.
Often, the primary key is a single
attribute.
In some tables however, two or more 23
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
A primary key is the
SCID
attribute or combination
333333333-1234 of attributes that
333333333-1236 uniquely identifies a
111111111-1235 specific row in a table.
111111111-1236
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE
SCID
333333333-1234 In some tables, two or more attributes
333333333-1236 may be joined to form the primary key.
111111111-1235
111111111-1236
Cont’d……..
Foreign key is an attribute appearing in
one table that is a primary key in another
table.
Foreign keys are used to link tables.
Other non-key attributes - in each
table store important information about
that entity.
Example, in the inventory table,
quantity on hand, description and list
price are non-key attributes.
26
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
A foreign key is an attribute in one table that is a primary key in
another table.
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
Foreign keys are used to link tables together.
STUDENTS
First Advisor
Student ID Last Name Name Phone No. No.
333-33-3333 Simpson Alice 333-3333 1418
111-11-1111 Sanders Ned 444-4444 1418
123-45-6789 Moore Artie 555-5555 1503
ADVISORS
Advisor No. Last Name First Name Office No.
1418 Howard Glen 420
1419 Melton Amy 316
1503 Zhang Xi 202
1506 Radowski J.D. 203
Other non-key attributes in each table store important
information about the entity.
Cont’d………
Basic Requirements of the Relational Data
Model
Every column in a row must be single
valued - there shall be one and only one
value in each cell.
Primary keys cannot be null - A non-null
value for primary key indicates that a specific
object exists and can be identified by
reference to its primary key value, referred to
as the entity integrity rule.
Foreign keys must have values that match to
the value of the primary key in another 30
Last First
Student ID Name Name Phone No. Course No. Section Day Time
333-33-3333 Simpson Alice 333-3333 ACCT-3603 1 M 9:00 AM
333-33-3333 Simpson Alice 333-3333 FIN-3213 3 Th 11:00 AM
333-33-3333 Simpson Alice 333-3333 MGMT-3021 11 Th 12:00 PM
111-11-1111 Sanders Ned 444-4444 ACCT-3433 2 T 10:00 AM
111-11-1111 Sanders Ned 444-4444 MGMT-3021 5 W 8:00 AM
111-11-1111 Sanders Ned 444-4444 ANSI-1422 7 F 9:00 AM
123-45-6789 Moore Artie 555-5555 ACCT-3433 2 T 10:00 AM
123-45-6789 Moore Artie 555-5555 FIN-3213 3 Th 11:00 AM
• Using the suggested approach, a student taking three classes would
need three rows in the table.
• In the above, simplified example, a number of problems arise.
STUDENTS
Last First Phone
Student ID Name Name No.
333-33-3333 Simpson Alice 333-3333
111-11-1111 Sanders Ned 444-4444
123-45-6789 Moore Artie 555-5555
COURSES
Course ID Course Section Day Time
1234 ACCT-3603 1 MWF 8:30
1235 ACCT-3603 2 TR 9:30
1236 MGMT-2103 1 MW 8:30
STUDENT x COURSE • The solution to the preceding problems is
SCID to use a set of tables in a relational
333333333-1234 database.
333333333-1236 • Each entity is stored in a separate table,
111111111-1235 and separate tables or foreign keys can be
111111111-1236 used to link the entities together.
Database Design Process
Data base design: the process of creation,
development, implementation and
maintenance of the data system.
how it work logically and physically
structured
A. Logical model : understanding the data
requirement
- how it should be organized
- A blue print that does not
depend on specific technical detail.
B. Physical model: implementing the logical
33
Database Design Process
1. Requirement analysis: planning and system
definition
2. Designing process: conceptual model, logical
model and physical model
3. Implementation stage
4. Data conversion and loading stage
5. Testing
6. Maintenance stage
34
1. Requirement analysis
1. Requirement analysis: planning and system
definition
Identifying and understanding the
fundamental requirements
Develop a comprehensive plan for the DDLC
Organization functional requirement
A. Planning: mapping out the entire DDLC,
organization requirement and strong function
B. System definition: build up on the planning
stage, boundaries and scope, set clear
parameters and limitation and purpose and
35
2. Designing process
Creating well structured database and
different model visualize and communicate the
data base design feature.
A. Conceptual model: user view of data,
organization to look at data, a conceptual
schema highlighting the database entities,
abstract view of data
B. Logical model: expanding conceptual model,
without considering specific DBMS or physical
implementation detail , understanding the
data needs, data element relate to each other ,
what information should be stored, how the
entities relate to one other. 36
Cont’d………
C. physical model: implementing logical
database design, software system the hard
ware resources and physical implementation
aspect and theoretical concept in practical
implementation
37
3. Implementation
Putting the designed database in action and
ensuring that is meet out requirements
Integration testing using different data sets
Convert the data into a format that the
computer can understand and process
efficiently
Data manipulation
Write and execute quires to inference with
database
Asses whether the application has been
designed stisfactory
38
4. Data conversion and load
stage
Smooth transition from the previous system to
the new database
Importing and covering data from the old
system into the new database
Ensuring comparability
Adapting the existing data to fit the structure
of the new database
Ensures a seamless transfer of data
Allowing for a successful migration from the
old system to new one
39
5. Testing
Ensuring the accuracy and functionally of new
system
Thorough examination of the database
Error
To validate the database
Meets the specified requirement and functions
correctly
Database aligns with the desired behavior
Fulfills the expected criteria
Quality assurance, accuracy, reliability and
effectiveness
40
Cont’d………
Data modeling occurs during both the
requirements analysis and design stages
of the database design process.
The Two important tools of data modeling;
Entity relationships diagramming and
REA data model
41
Relationship: is association among 2 or more
Entity Relationship Diagrams
entities
teacher--- teaches--- student
An entity relationship (E-R) diagram is a
graphical technique for showing a database
schema.
Shows the various entities being modeled
and relationships among them.
Entities appear as rectangles and
relationships between entities are
represented as diamonds.
42
Entity Relationship Diagrams
Degree of relationship: denotes number of
entity types that participate in relationship.
A. Unary relationship: exists when there is an
association with one entity
B. Binary relationship: exists when there is an
association among two entities
C. Ternary relationship: exists when there is
an association among three entities
43
REA Data Model
The REA model is an accounting framework for
modeling an organization’s critical resources,
events, and agents and the relationships
between them.
REA model classifies entities into three
categories:
Resources - the organization acquires to use,
Events (business activities) - which the
organization engages on, and
Agents participating in the events.
44
Cont’d……..
The events in REA data model fall into one of
the two categories:
Economic exchanges or
Commitments
Economic exchanges - value chain activities
that directly affect the resources.
E.g. Sales event decreases the inventory
and the cash receipts event increases the
amount of cash.
Commitments - promises to engage in future
economic exchanges.
E.g. Customer orders are commitments that
45
Cont’d………
Events such as the sale of merchandise that change the
quantity of a resource are linked to that resource in what is
called a stock flow relationship.
Other events such as taking a customer order that represent
future commitments are linked to resources called reserve
relationships.
Each event is linked to two agent entities.
Internal agent is the employee who is responsible for the
resource affected by the event.
External agent is the outside party to the transaction.
Each economic exchange event is linked in a give to get
duality relationship with another economic exchange event.46
Basic REA template
Cont’d……….
Resource A GET
Inflow Participant Internal Agent
Resource A
Participant External Agent
Economic
Duality
Participant External Agent
GIVE
Resource B Outflow Participant Internal Agent
Resource B
©2003 Prentice Hall Business Publishing,
47
5-21
Cont’d……….
Developing
REA diagram for a specific
transaction cycle consists of four steps:
Identify the pair of economic exchange
events
Identify the resources affected by each event
and the agents who participate.
Analyze each economic exchange event
Determine the cardinalities of each
relationship.
Step 1: Identify Economic Exchange Events
The basic REA template consists of a pair48 of
Cont’d……..
The events are drawn as rectangles and the
economic duality relationship between them
as a diamond.
In drawing REA model, the paper is divided
into three columns-one for each type of entity:
The left column is used for resources,
The center column for events, and
The right column for agents.
The event entities are drawn from top to
bottom corresponding to the sequence in
which they occur. 49
Cont’d……….
Step 2: Identify Resources and Agents
Resources affected by the events need to
be identified
The sales event is translated to giving
inventory to customers and the cash
receipts event is translated to receiving
cash from customers.
Hence, the inventory and cash entities are
added in the resource column.
A/R is not modeled as a separate entity
because it is not an independent object but
50
Cont’d……..
Identify the agents who participate in
the events.
There will always be at least one internal
agent (employee) and external agent
(customer or vendor) who participate in
each event.
For example,
Customers and salespersons
participate in the sale event, and
Customers and cashiers participate in
the cash collection event. 51
Sample REA diagram
Inventory Stock-flow Sales Participant Salesperson
Participant
Economic
Customer
Duality
Participant
Cash
Cash Stock-flow Participant Cashier
Receipts
©2003 Prentice Hall Business Publishing, 5-22
Accounting Information Systems, 9/e, Romney/Steinbart
52
Step 3: Include Commitment Events
It is important for management to get up to date information
about various orders to reorder various inventory items.
It is also important to know which orders have been shipped
and when
Example; the economic exchange event labeled sales may
be replaced with a combination of a commitment event
labeled customer orders.
53
Cont’d………
Step 4: Determine the Cardinalities of
Relationships
The nature of relationships b/n the various
entities.
Indicate how many instances of one entity can
be linked to one specific instance of another
entity.
For example, how many sales transactions
can be linked to each individual customer
and, conversely, how many customers can be
linked to each individual sales transaction.
54
Cont’d……….
It indicates whether a row in the table must
be linked to at least one row in the table on
the opposite side of that relationship.
A minimum cardinality of 0 means that a new
row can be added to that table without being
linked to any specific rows in the table on the
other side of the relationship.
The second number in each cardinality pair is
the maximum cardinality.
It indicates whether one row in a table can be
linked to more than one row in the other
table. 55
Cont’d………
A maximum cardinality
of 1 means
that each row in that table can be
linked to at most only one row in
another table.
Documentation of
Business Practices
The zero minimum for the sales event indicates
that credit sales are made
The N maximum for the sales event means that
customers may make installment payments
Cash Sales-
Cash Receipts Sales
Receipts (1, N) (0, N)
©2003 Prentice Hall Business Publishing,
Accounting Information Systems, 9/e, Romney/Steinbart
5-56 56
REA diagram for a sample revenue cycle
Customer
Inventory- (1,N) (1,1) Participant (0,N) Customer
Orders
Orders
(0,N) (1,1)
(0,1) Participant
(0,N)
Inventory- Leads to
Inventory (0,N) Salesperson
Sales (0,N)
(0,1)
(1,N)
Participant
(1,1)
Sales
(1,1) Participant (0,N) Customer
©2003 Prentice Hall Business Publishing, 5-28
Accounting Information Systems, 9/e, Romney/Steinbart
57
Cont’d………
Three basic types of relationships
between entities are possible depending
on the maximum cardinality.
A one to one (1:1) relationship exists
when the maximum cardinality for each
entity in that relationship is one.
A one to many (1:N) relationship
exists when the maximum cardinality of
one entity in that relationship is 1 and
the maximum cardinality of the other
entity in that relationship is N
Many to many (M:N) relationship 58
Cont’d…………
Rules for Specifying Cardinalities
Cardinalities don’t select arbitrarily.
Cardinalities reflect facts about the
organization being modeled and its business
practices.
Cardinality Rules for Agent-Event
Relationship
The minimum and maximum cardinalities
associated with the event entity in every agent-
event relationship will be both 1.
The minimum cardinality is 1 because there
must be an agent who participates in that 59
Cont’d………
The cardinalities associated with each
agent entity in the agent-event
relationship all have zero minimums and N
maximums.
The maximum cardinality associated
with internal agent entities is almost
always N, because organizations expect
their employees will participate in
numerous events.
It is also usually N for external agents,
because organizations often engage in60
Cont’d……….
why the minimum cardinality associated
with agent entities in the agent-event
relationship is usually zero:
Organizations want to be able to add
information about potential customers
and suppliers even though those agents
may not have participated yet in the
business transactions
61
Cont’d……….
Cardinality Rules for Resource-Event
Relationships
The minimum and maximum cardinalities
associated with each resource in
resource-event relationship are zero and
N, respectively.
The minimum cardinality associated with
event entities in resource-event
relationship is usually 1.
For example, each sale event must
include at least one row in the inventory62
Cont’d………
Cardinality Rules for Event-Event
Relationships
Any kind of cardinality pair is possible for
each event entity in event-event
relationships.
The organization's business practices and
policies must be understood to decide
which possibility is correct.
For example, collections from customers
may be at once (1:1) or in installments
(1: N). 63
Cont’d………
Implementing an REA diagram in a
relational database is a three-step
process:
Create a table for each distinct entity
and for each many to many relationships
Assign attributes to appropriate tables
Use foreign keys to implement one to
one and one to many relationships.
64
Questions?
Thank you!
65