Topic 05
Topic 05
Department of Finance
E-Mail – [email protected]
Managing Entity
Data Relationship
Resources Modelling
Program-data dependence:
Lack of flexibility:
Poor security:
• Because there is little control or management of data, management
will have no knowledge of who is accessing or even making
changes to the organization’s data.
Lack of data sharing and availability:
• Information cannot flow freely across different functional areas or
different parts of the organization. Users find different values of the
same piece of information in two different systems, and hence they
may not use these systems because they cannot trust the accuracy
of the data.
Types of Databases:
• Relational DBMS
• Object-oriented databases
Relational DBMS:
Let’s examine some basic principles about how data are stored in
computer systems.
– An entity is anything about which the organization wishes to store data. At your
college or university, one entity would be the student.
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
22 of 95
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
– A set of all related records forms a file (e.g., the student file).
– If this university only had three students and five fields for each
student, then the entire file would be depicted below.
STUDENTS
Phone
Student ID Last Name First Name Number Birth Date
Student Class
File File
Advisor
File
BBFE 21342– Management Information Syste 25
ms
Importance and Advantages of Database
Systems
– Reporti
ng flexibility
the program and vice versa.
Makes programming easier and simplifies data management.
– Minimal
data redundancy and inconsistencies
– Data independence
– Reporting fl
exibility
Data management is more efficient because the database
administrator is responsible for coordinating, controlling,
– Minimal dat a redundancy and inconsistencies ndence
and managing data.
– Data indepe
– Central management of data
– Cross-functional analysis
• Physical view
How and where the data are physically
arranged and stored.
BBFE 21342– Management Information Syste 34
ms
Database Systems
Jr.
38%
Database
BBFE 21342– Management Information Syste 36
ms
Logical View—User A Logical View—User B
Enrollment by Class Scholarship Distribution
Fr.
5%
Sr. Soph.
33% 24%
Jr.
38%
DBMS
The operating system
Operating translates DBMS
System requests into
instructions to
physically retrieve
data from various
Database disks.
• Schemas
– A schema describes the logical structure of a database.
– There are three levels of schema.
• Conceptual level
Arnold . . .D
Cash
Receipt
• Schemas
– A schema describes the logical structure of a
database.
– There are three levels of schema.
• Conceptual level
• External level
• A set of individual user views of portions of
the database, i.e., how each user sees the
portion of the system with which he
interacts.
• These individual views are referred to as
subschema.
BBFE 21342– Management Information Syste 42
ms
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D
Cash
Receipt
• Schemas
– A schema describes the logical structure of a
database.
– There are three levels of schema.
• Conceptual level• A low-level view of the database.
• External level • It describes how the data are actually
stored and accessed including:
• Internal level – Record layouts
– Definitions
– Addresses
– Indexes
BBFE 21342– Management Information Syste 44
ms
Subschema--User A Subschema--User B Subschema--User C
Smith . . . A
Jones . . . B
Arnold . . .D
Cash
Receipt
Arnold . . .D
The
Classes Enroll Student bidirectional
arrows
represent
mappings
Cash
between the
Receipt
schema.
• DBMS Languages
– Every DBMS must provide a means of
performing the three basic functions of:
• Creating a database
• Changing a database
• Querying a database
• Creating a database:
– The set of commands used to create the
database is known as data definition
language (DDL). DDL is used to:
• Build the data dictionary
• Initialize or create the database
• Describe the logical views for each individual user or
programmer
• Specify any limitations or constraints on security
imposed on database records or fields
BBFE 21342– Management Information Syste 52
ms
Database Systems
• Changing a database
– The set of commands used to change the
database is known as data manipulation
language (DML). DML is used for
maintaining the data including:
• Updating data
• Inserting data
• Deleting portions of the database
• Querying a database:
– The set of commands used to query the database is known
as data query language (DQL). DQL is
used to interrogate the database, including:
• Retrieving records
• Sorting records
• Ordering records
• Presenting subsets of the database
– The DQL usually contains easy-to-use, powerful
commands that enable users to satisfy their own
information needs.
BBFE 21342– Management Information Syste 54
ms
Database Systems
• Report Writer
– Many DBMS packages also include a report writer, a
language that simplifies the creation of reports.
– Users typically specify:
• What elements they want printed
• How the report should be formatted
– The report writer then:
• Searches the database
• Extracts specified data
• Prints them out according to specified format
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
BBFE 21342– Management Information Syste 59
ms
Relational Databases
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
333333333-1236
111111111-1235
111111111-1236 BBFE 21342– Management Information Syste 61
ms
STUDENTS Each row
Last First Phone
contains data
Student ID Name Name No. about a specific
occurrence of
333-33-3333 Simpson Alice 333-3333
the type of entity
111-11-1111 Sanders Ned 444-4444
in the table.
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
333333333-1236
111111111-1235
111111111-1236 BBFE 21342– Management Information Syste
ms
62
STUDENTS Each column in
Last First Phone a table
Student ID Name Name No. contains
333-33-3333 Simpson Alice 333-3333 information
111-11-1111 Sanders Ned 444-4444 about a specific
123-45-6789 Moore Artie 555-5555 attribute of the
entity.
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
333333333-1236
111111111-1235
111111111-1236 BBFE 21342– Management Information Syste
ms
63
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
specific row in a table.
111111111-1235
111111111-1236 BBFE 21342– Management Information Syste
ms
64
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
BBFE 21342– Management Information Syste 65
ms
STUDENTS
Advisor
Student ID Last Name First 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
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
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
• If Ned withdraws from all his classes and you eliminate all three of
his rows from the table, then you will no longer have a record of
Ned. If Ned is planning to take classes next semester, then
you probably didn’t really want to delete all records of him.
• This problem is referred to as a delete anomaly.
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 • The solution to the preceding problems
COURSE
is to use a set of tables in a relational
SCID
database.
333333333-1234
• Each entity is stored in a separate table,
333333333-1236
and separate tables or foreign keys can
111111111-1235 be used to link the entities together.
111111111-1236 BBFE 21342– Management Information Syste 76
ms
Relational Databases
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
• Note that within each table, there are no
SCID
duplicate primary keys and no null
333333333-1234 primary keys.
333333333-1236
• Consistent with the entity integrity rule.
111111111-1235
111111111-1236 BBFE 21342– Management Information Syste 79
ms
Relational Databases
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
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 • Add a course here.
SCID • Leaves no blank spaces.
333333333-1234
333333333-1236 • When a particular student enrolls for a
111111111-1235 particular course, add that info here.
111111111-1236 BBFE 21342– Management Information Syste 85
ms
Relational Databases
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 • Even if Ned was the only student in
SCID the class, ACCT-3603 still exists in
333333333-1234 the course table.
333333333-1236
• If Ned Sanders drops ACCT-3603,
111111111-1235
remove Ned’s class from this table.
111111111-1236 BBFE 21342– Management Information Syste 87
ms
Creating a Database Environment
Designing Databases:
Exampe1: City
Example2:Customer id
Example : age, and its value is derived from the stored attribute Date
of Birth. BBFE 21342– Management Information Syste 94
ms
Entity Sets INSTRUCTOR and STUDENT
Representing entities
we represent an entity by a named rectangle
use a singular noun, or adjective + noun
refer to one instance in naming
Representing relationship
Types of Relationships
Three types of relationships can exist between entities
Types of Relationships
Many-to-many relationship (M:N): exists when one instance of the first entity
(parent) can relate to many instances of the second entity (child), and one
instance of the second entity can relate to many instances of the first entity.
Many to many
BBFE 21342– Management Information Syste 101
ms
Cardinality Constraints
One-to-one relationship:
A student is associated with at most one instructor via the
relationship advisor
A student is associated with at most one department via
stud_dept
1 1
1 1
1 1
A foreign key is generally a primary key from one table that appears as a field in
another where the first table has a relationship to the second. In other words, if
we had a table A with a primary key X that linked to a table B where X was a field
in B, then X would be a foreign key in B
{Student ID,FirstName }
{Student ID, LastName }
{Student ID,FirstName,LastName}
An entity set that does not have a primary key is referred to as a weak entity set
Representing attributes
Rectangle -- Entity
Ellipses -- Attribute (underlined attributes are [part of] the primary key)
Dashed ellipses-- derived attribute, e.g. age is derivable from birthdate and
current date. BBFE 21342– Management Information Syste 115
ms
Summary of Symbols Used in E-R Notation
Representing attributes