Sie sind auf Seite 1von 76

R.

John Martin
Lecturer in IT, Higher College of Technology Sultanate of Oman

Data & Information


Data 1 2 3 Data is collection of facts and figures No conclusions can be drawn on data. Data is raw material for processing. It is processed further. It is not time bound Information Processed form of data is information Used to draw conclusions. Info. Can also be further utilized to produce high quality information. It is time bounded.

E.g.

An amount of money withdrawn from an account on particular day is a data. This data is further used for preparing balance sheet, profit-l loss statement etc. when such processing is done on data, it is called as information. So information is processed form of data

Data vs. Information

Data - a collection of facts made up of text, numbers and dates: Ahmad 35000 7/18/86 Information - the meaning given to data in the way it is interpreted: Mr. Ahmad is a sales person whose annual salary is $35,000 and whose hire date is July 18, 2006.

What is a Database
Database is an organized collection of inter related information. It is a collection of persistent data that can be shared & interrelated. Persistent Data reside on stable storage such as magnetic disk and available for ever. Interrelated Data stored as separate units can be connected to provide a whole picture. It contains conventional & non-conventional information. Conventional information - facts about persons, things, events etc., Non-conventional information - photographs, fingerprints, videos etc.,

Database, Database System & DBMS


Database is an organized collection of interrelated

information. When we perform some operation on the data and organize in some meaningful format, it is called as database system.
The software which allows user to create (table creation) and

maintain (insert, delete, change) database is called Database Management System (DBMS).
DBMS MS-Access, ORACLE, Ingres, INFORMIX,

SyBase, PostgreSQL, MS-SQL Server.

DATA BASE MS

Components (Resources) of a Database System


1.
2.

Data - (Data / Information)


Hardware ( Computer, Secondary Storage Devices, Processor, Input/Output Devices etc.,) Software Set of programs. (DBMS)

3. 4.

Users - (Application Programmers, End-Users, DBA)

Database Approaches
There are two approaches for storing and maintaining the data on persistent storage.

PROGRAMMER (Application Program)

FILE-BASED SYSTEM

DATA BASE SYSTEM

FILE-BASED SYSTEM
Each programmer has their own set of data without

having any link to the other.

They are independent systems (stand alone) Application programs cannot exchange information.

EXAMPLE
STUDENTS REGISTRATION STUDENTS AFFAIRS TEACHERS

Students Registration Details

Student Information

Attendance Report

Own set of data No link / sharing Works independently Changing is be done separately

Elements of a database:
Database consists of three major elements. 1. Entities 2. Relationships 3. Procedures

Entity an entity can denote a person, place, thing or event.


Example: Employees, Departments, Students, Course, Registration etc.,

Relationship it represents a link or a relationship between the entities.


Example : Employees working in a department, Students registered for a course.

Procedures - An ordered set of tasks/rule for performing some action on the database.
Example : Teachers assignment, Course Scheduling, Registering students.

Find the entities, relationships and procedures in the following problem.


Business department wants to create a database which will store information about all the students those who are studying the department, all the teachers working in the department, list of courses offered, the information about the courses allotted for a teacher, students registered for a particular course, and teacher for a particular course, using the above information, Students registration, add course and drop course should be done successfully.

EXAMPLE 1 : COLLEGE DATABASE

Entities: Students Teachers Courses Department Relationships: Course - Teacher Student Course Teacher - Department

Drop Course

Add course

Registering students

Find the entities, relationships and procedures in the following problem


In a Hypermarket a database is maintained to store the information about all the products that are available in that shop, all the employees working, the shopping carts available and the details of the customers. Whenever any customer comes to the shop, the customer should collect all the products he need in a shopping cart, if he needs any help, he can contact any employee of the shop and finally a bill should be generated by an employee and stock should be updated for all the products.

EXAMPLE 2 : HYPERMARKET DATABASE

Entities: Customers Products Employees Shopping-cart Relationships: Products - Customer Customer Shopping Cart Shopping Cart - Products Stock Updating

Billing

DATABASE SYSTEM

It is a computerized record keeping system.


Its purpose is to maintain information and make that

information available to all users anytime they are required.


The information kept in a database can be anything that

is important to the company or organization.

DATABASE SYSTEM (Cont..)

In a database system, data kept in the computer will be

integrated and shared by users.


Integrated means that the database can be thought as a

collection of information where repeated data are removed from the system.
Shared means that individual pieces of data in a database

can be shared among different users.

DATABASE SYSTEM

STUDENTS AFFAIRS

Students Personal Information Students Attendance Students Result

DATABASE

HEAD OF THE DEPT

LECTURES

Apply File-based / Database Approach


College maintains a file named personal information to

store the details of the students such as Student-Id, Studentname, Specialization, Address, School-details, Emergencycontact number.
Apart from personal information, the college is also

maintaining a separate file named student results to store the results of the results of the students which consists of Student-Id, Student-name, Specialization, Result.
A separate file named students attendance is maintained to

store the attendance details of the students which consists the student-Id, Student-name, date-of-absent and period.

Apply file-based / Database approach In a Hypermarket a file named Product-file is used to store the information about all the products like Product-number, Product-name, Unit, Price, Stock. A separate file named Employee-file is used to maintain the details of the employees, like Employee-number, Employeename, Date-of-birth, Emp-Address, Salary. Another file named Customer-file is used to store the customer details such as Customer-no, Customer-Name, Cust-Address. A file named Sales-file is used to store the sales details such as Product-no, Product-Name, Customer-no, customername, units, price, total-amount.

Objectives and Need of Database System


To specify information requirements of user. To provide ad-hoc reports ( which are not required regularly) To provide a natural and easy way of structuring of data. To support the processing requirements & any performance

objective.
To design data structure which will remain robust over time.

(i.e. new information can be easily added to database)

Lab Exercise : Ms-Access Introduction, Working with tables, Table formatting

Advantages of database approach


1. 2. 3. 4. 5. 6.

Redundancy of data can be reduced. Inconsistency can be avoided Data sharing Security restrictions can be applied Integrity can be maintained Data independence

1. Redundancy of data can be reduced

Here College_Id, Student_name, Specialization is repeated in


PERSONAL INFORMATION, STUDENT RESULT AND STUDENT ATTENDANCE.

That is redundancy (repetition of information)

2. INCONSISTENCY CAN BE AVOIDED


PERSONAL INFORMATION

College-ID 1001
STUDENTS RESULT

Student-Name SALIM

Specialization IT

Address MUSANNA

College-ID 1001

Student-Name SALIM

Specialization ENG

Result PASS

STUDENTS ATTENDENCE

College-ID 1001

Student-Name SALIM

Specialization IT

Attendance % 79

Inconsistency means incorrect information or confusing information.

3. DATA SHARING

STUDENTS AFFAIRS

Students Personal Information Students Attendance Students Result

HEAD OF THE DEPT

LECTURES

Data is easily available to all users in database system as it is shared.

4. SECURITY RESTRICTIONS DBA - Database Administrators, USERS Permissions to access, modify or delete data. DBA creates users and give rights (permissions) to them to access, modify or deletion of information from table. Data is more secure in database system than file based system.

5. DATA INTEGRITY

STUDENTS AFFAIRS

Students Personal Information Students Attendance Students Result


HEAD OF THE DEPT

LECTURES

Data that we are storing in database must satisfy some condition is called data integrity.
e.g: age > 0. such conditions are easily given in database.

The user can rely on the data given by the system because of Security restrictions and elimination of Data redundancy.

6. DATA INDEPENDENCE
Data Structures (Table Design) can be changed without changing the application programs.

USERS

APPLICATION PROGRAMS

DATA

DATABASE MANAGEMENT SYSTEM

Database + Application Programes =DBMS


DB Collection of data. AP - Collection of Programs (Software) to maintain database.

Database Operations (Maintenance):


Insert new information Retrieve existing information Delete existing information Modify existing information Store the information Distribute the information Format the information

Benefits of DBMS

Sharing of data and common interface is provided by DBMS. Less redundancy. Efficient and easy data access. Data integrity is maintained. Provides security for data. Data administration is easy. Standards can be enforced. User need not require to know about location of data on the disk. Reduced application development time.

Disadvantages (Drawbacks) of DBMS:


Use of expensive hardware and software i.e. it is costly. Difficult and costly to develop, because it needs trained professionals, persons. Centralized data. Complete shut down when subject to failure.

Database Applications:
Banking: all money transactions Airlines: reservations, schedules Universities: registration of students, results of students. Sales: customers information, products info., purchases info. Online retailers: order tracking, customized recommendations Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions Databases touch all aspects of our lives

Types of Data Models

Data Model is a design of database.


Data model defines how data is organized, stored and retrieved in database. It shows data and their relationship. There are 3 models.

Hierarchical Model Network Model Relational Model

1.

Hierarchical Model

It is a database management system that link records together like ordered tree.

The Relationship is One-To-Many Relationship is unidirectional

Data is shown by rectangles Relationship is shown by lines

Example
A Parent

Childs

Hierarchical Model ( Like Tree structure)


Disadvantages: 1. Slow in processing. 2. Difficulty in getting data. 3. Difficult programs are required to write to get data.

2. Network Model
Used in early days Data is shown by rectangles Relationship is shown by lines It is shown like arbitrary graph. The Relationship is a Many-To-Many Relationship is unidirectional

Example
D

A
E B F C G

Network model ( Like graph)

Disadvantages: Slow in processing than relational model. Difficulty in getting data. Difficult programs are required to write to get data.

3. Relational Model
Collection of tables are used to show data and their

relationship.
Data is stored in 2 dimensional tables. Table is collection of rows and columns. In relational database

Rows are called tuples. Columns are called attributes.

Example
Data and Relationship shown by two tables. Table name Column/ Attributes STUDENT
Stud_id 1 Name Ali Mohammad Course IT ENG

STUDENT-MARKS
Stud_id Marks Mobile_No

78

95746111

Row/
Tuple
2 2 67 95111111

80

95746333

Relational model using 2 tables

Relational Database is a set of relations.


Relation is a table with rows, columns and is made up of two parts namely schema and instance. Schema specifies name of relation plus name and type of each column. For example, Student Table
Sid Name Specialization GPA Number Text Text Number

Instance is a table with rows, columns and row data.For example,


Sid 111 222 333 Name Ali Muna Huda Specializatio n IT IT IT GPA 3 2.5 3.2

INTEGRITY CONSTRAINTS
Integrity constraints are conditions that must be true for any instance of a database. A legal instance of a relation is one that satisfies all specified Integrity constraints. Integrity constraints are specified using keys.
KEYS
A set of fields is a key. Keys provide one form of integrity

constraints. Keys are a way to associate rows in different relations.


Super key: column(s) with unique values Candidate key: a key, although not selected as a primary key, can

also be used to uniquely identify a row or entity.


Null value: special value meaning value unknown or inapplicable

Primary key:
A primary key is a field (or combination of fields, called a composite key), which uniquely identifies a row or entity.
For example consider the following student table,
Sid Name Specialization GPA

Sid and {Sid, GPA} are super keys. Chose any one as primary key, for instance Sid. The other key becomes candidate key.

Foreign Key:
a field in one relation, which refers to a field in another. Foreign

keys are used in relational schema to represent a relationship between two relations/entities. A foreign key in one relation refers to the primary key field of the related relation/entity.
an attribute/field or combination of attribute in a table whose value

match primary key in another table.


Enrollment Student

Sid
111 222 111

Cid
ITSE1100 ITDB1102 ENGL1100

Grade
A B C+

Sid
111 222 333

Name
Ali Muna Huda

Login
T015 T026 T018

GPA
3.2 3.3 3.0

111

ITSE1101

B+
Sid Primary Key

(Sid, Cid) - Primary Key Sid - Foreign key

Entity integrity: primary keys


Each table has column(s) with unique values. That is no two rows of a table can contain the same value for the primary key. In addition, no row can contain a null value for any columns of a primary key.
For example, the primary key Sid is unique in the

following table.
Sid
111 222 333 444 Ali Huda Muna Muna

Name

Specializat ion
IT IT ENGG IT 3.2 3 3.3 3.0

GPA

Referential integrity: foreign keys


Ensures valid references among tables

Foreign keys can be null in some cases


Foreign keys must match primary key of referenced table.

For example, Sid is foreign key in Enrollment its values match with the Student tables Sid.
Enrollment Student

Sid
111 222 111 111

Cid
ITSE1100 ITDB1102 ENGL1100 ITSE1101

Grade
A B C+ B+

Sid
111 222 333

Name
Ali Muna Huda

Login
T015 T026 T018

GPA
3.2 3.3 3.0

(Sid, Cid) - Primary Key Sid - Foreign key

Sid Primary Key

Data Model
A data model is an overall design of a database. It shows a data and relationship between them. It is a conceptual tool to represent the database.

The data model focuses on what data is required and

how it should be organized.

The design of the database is a step-by-step procedure. It can be divided into three separate stages

Conceptual data modeling Logical schema construction Physical database design

For small projects the above stages can be handled by one person only, whereas in big projects each stage can be handled by separate persons.

Conceptual data Modeling

Logical Schema Construction

Physical Database design

Big Projects

Conceptual data Modeling Logical Schema Construction Physical Database

Small Projects

Phases of Database Design


Database Requirements

Conceptual Data Modeling


E R Diagram (on papers)

Logical Schema Construction

Relational Database Tables (on papers)

Physical Database Design

Schema and Instances (Inside computer)

A) Conceptual Data Modeling


It includes objects ( i.e. documents ) of an interest to

an organization. E.g. Al Musanaa College of Technology.

Personal information Name - Ali Al Balushi Section -1 DOB - 04-Dec-1988 Address - Muladha Hostel - Yes GPA - 2.67

Level Levelcode - 101 Leveldesc -Certificate

B) Logical Schema Construction


Based on data provided by conceptual model, the database

structure is designed on paper. This is known as logical schema construction.


Student Table
Field Name StudId Name Section DOB Address InHostel LevelCode CourseCode Data Type Number Text Number Date Text Logical Number Number Integer Integer dd-mmm-yyyy 40 Field Size Long Integer 30 Format Decimal

Level Table
Field Name LevelCode LevelDesc DataType Number Text Field Size Format Decimal

During the logical schema construction, the following can

be determined.
What element of data you will store? How large each element can be? What kind of information each element can contain? What elements may be left blank? Which elements are considered to be of a fixed range? Whether and how various tables are linked?

C) Physical Database Design


It refers to the actual structures created inside the computer.
Based on data structure designed on paper in the logical

schema construction stage, actual structure are created inside computer.

Student Table Computer Level Table

Attendance Table

Course Table

Physical Database Design:


Student Table Created In Ms-Access (DBMS)

Conceptual Modeling
This is the first step of database design. Relevant elements are identified and analyzed. Such as

documents like daily attendance report, students grading sheet and objects like teacher, student, library.
To analyze the information, data modeling techniques are

used.
Data Modeling techniques areA) Entity Relationship Diagram. (ERD) B) Normalization. C) Functional Dependency Diagram. (FDD)

Output of the analysis is called Conceptual Data.

A) Entity Relationship Diagram (ERD)


1976 proposed by Peter Chen

Entity Relationship Diagram is a conceptual data modeling

technique which shows all entities and the relationship exists between them.
Entity Relationship Diagram is a graphical representation of

a database.
Entity Relationship Diagram
CustCity

CustID

Customer

Depositor

Account

ActNo

CustName

DOB

Balance

In Entity Relationship Diagram


Rectangle Diamond Ellipses

represents - Entity Set represents Relationship Set represents Attributes

Symbols Used to show relationship between the entities


One-to-One (1:1) One-to-Many (1:M) Many-to-Many (M:M)

The conceptual model is often stated in terms of:


Entities an entity is an object about which information is

collected. This can be person (i.e. student, teacher), place (i.e. department), things (grade) or events (attendance).
Entity set Group of similar entities.

e.g. all person, all places.


Attributes Attributes are the properties or characteristics of an

entity. e.g. StudId, StudName, DOB, Address.


Entity Occurrence It is an instance of an entity. i.e. set of

values , usually records or tuple.

Relationship In database relationship must exists between

entities.
Relationships are classified by their degree, connectivity,

cardinality, direction and type


Attribute Domain Each attribute has permitted set of values

called attribute domain. E.g.


Date might be dd-mmm-yyyy thus 10-May-1980 is valid, but

10/05/1980 not valid for domain of attribute date.


If we give condition salary >= 1000 and salary<=2000 then domain

of salary attribute contain all values between 1000 and 2000 (e.g. 1500, 1890, 1999, 2000)

Degree of a Relationship

The degree of relationship is the number of entity sets associated (linked) with the relationship.

Binary relationship- It is an association between two entity sets


Degree = 2

Ternary Relationship It involves three entity sets.


Degree = 3

N-Ary Relationship More than three entity sets are involved in

relationship

Degree = 5

Mapping Cardinality Mapping cardinality shows how entities of one entity

set associated with another entity set via a relationship set. One To One (1:1) One To Many (1:M) Many To One (M:1) Many To Many (M:M)

One-to-One (1:1)
At most one instance of entity set A there is only

one instance of entity set B. And at most one instance of entity set B there is only one instance of entity set A. A B
e.g. Car CarNumber Country - CapitalCity Department - HeadOfDepartment

One-one

One-to-Many (1:M)
For one instance of entity set A , there are zero, one

or many instances of entity set B. But for one instance of entity set B there is one instance of entity setBA. A
e.g.

only

One Department - Many Student

One-to-Many

Many-to-One (M:1)
For one instance of entity set B , there are zero, one

or many instances of entity set A. But for one instance of entity set A there is one instance of entity setBB. A
e.g.

only

Many Student One Course

Many-to-One

Many-to-Many (M:M)
For one instance of entity set A , there are zero, one or

many instances of entity set B. But for one instance of entity set B there is many instances of entity set A. B A
e.g. Employee Project Suppliers Part Author - Book Many-to-Many

One-to-Many

Consider another entity set; Department and Courses. Looking at figure below we can say that ONE department can offer MANY courses.

Marketing

Business Studies

Business Ethics

E-Business

Many-to-Many

Consider another entity set Students and Courses. Looking at figure below we can say that ONE Student is registered to MANY courses and Courses has MANY Students.
Ali Marketing

Ismail

Business Ethics

Haider

E-Business

Example ER Diagram.

CUSTOMER

HAS

ACCOUNT

HANDLES

BANK

Relationship with linking words/phrases-

Relationships are also sometimes expressed in verbs (action words). e.g. Department Head manages Department. On the other hand Department is managed by Department Head. A Department Head can manage only ONE department and department can have only ONE head ( 1:1 relationship)
Department Head
Manages a Managed by

Department

MR X One-to-One

IT Department

References: Course Text Book


Title : Database Design, Application Development and Administration Author: Michael V.Mannino ISBN:0-07121489-5 Chapters: 1 , 2 and 5

E-brary Book
Title: Databases A Beginner's Guide Author: Oppel, Andy ISBM:9780071608473 Chapters: 1,7

Das könnte Ihnen auch gefallen