Lecture 1: Introduction to Database - Nubacad.com
Lecture 1: Introduction to Database - Nubacad.com
Lecture 1: Introduction to Database - Nubacad.com
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
MIS 4102 :<br />
<strong>Database</strong> Management Systems<br />
Md. Zahidul Hasan<br />
<strong>Lecture</strong>r<br />
Dept. of Computer Science and Engineering<br />
Northern University Bangladesh<br />
<strong>Lecture</strong> 1<br />
<strong>Introduction</strong> <strong>to</strong> <strong>Database</strong><br />
Management System<br />
Data and Information<br />
• Data – A collection of raw facts and figures.<br />
Data is an encoded representation of<br />
information.<br />
• Information – Final product created from the<br />
raw data after processing. So, Information is<br />
summarized data or otherwise manipulated<br />
(processed) data.<br />
• Information systems process and manage<br />
data. Data Management involves<br />
“Capturing”, “Retrieval” and “S<strong>to</strong>rage” of<br />
data.<br />
3<br />
• A database is collection of data, or<br />
information that is organized so that specific<br />
information can be easily located and<br />
retrieved.<br />
Examples:<br />
• Phone book<br />
<strong>Database</strong><br />
• University grading system<br />
• Airline reservation system<br />
4<br />
1
<strong>Database</strong> Management System (DBMS)<br />
• A database management system (DBMS) is an<br />
integrated collection of programs that are used<br />
<strong>to</strong> create and manage information in a database.<br />
• Examples:<br />
• Microsoft Access<br />
• Oracle<br />
• SQL Server<br />
• MySQL<br />
• DBMS contains information about a particular<br />
enterprise.<br />
5<br />
<strong>Database</strong> Management System (Cont…)<br />
• Four basic functions performed by all DBMS<br />
are:<br />
• Create, modify, and delete data structures, e.g.<br />
tables<br />
• Add, modify, and delete data<br />
• Retrieve data selectively<br />
• Generate reports based on data<br />
6<br />
<strong>Database</strong> Management System (Cont…)<br />
• <strong>Database</strong> Applications:<br />
• Banking: transactions<br />
• Airlines: reservations, schedules<br />
• Universities: registration, grades<br />
• Sales: cus<strong>to</strong>mers, products, purchases<br />
• Online retailers: order tracking, cus<strong>to</strong>mized<br />
re<strong>com</strong>mendations<br />
• Manufacturing: production, inven<strong>to</strong>ry, orders, supply chain<br />
• Human resources: employee records, salaries, tax<br />
deductions<br />
• <strong>Database</strong>s <strong>to</strong>uch all aspects of our lives<br />
Why Use a DBMS<br />
7<br />
8<br />
2
Past System for Managing Information<br />
The File Systems Approach<br />
• The information is s<strong>to</strong>red in permanent system files.<br />
• A number of application programs are written <strong>to</strong><br />
manipulate the files.<br />
General<br />
Ledger<br />
File<br />
Production<br />
Planning<br />
File<br />
Invoicing<br />
File<br />
Despatch<br />
File<br />
Personnel<br />
File<br />
Payroll<br />
File<br />
Inven<strong>to</strong>ry<br />
File<br />
Order<br />
Entry<br />
File<br />
Sequential Files<br />
File Organisation<br />
• records are s<strong>to</strong>red in a fixed sequence<br />
• records can only be read in that sequence, starting from<br />
the first record<br />
• records can only be added at the end of the file (append)<br />
• sequential files are not efficient<br />
Indexed Files<br />
• Use an index <strong>to</strong> access records in a random fashion.<br />
• Records can be sorted according <strong>to</strong> an attribute or<br />
preference. (e.g Alphabetically, Ascending, Descending,<br />
etc.)<br />
• Indexed files are efficient, and faster <strong>to</strong> access.<br />
9<br />
10<br />
Disadvantages of File Processing System<br />
• Data Redundancy: Data Redundancy means<br />
same information is duplicated in several files.<br />
• Data Inconsistency: Data Inconsistency means<br />
different copies of the same data are not<br />
matching. That means different versions of same<br />
basic data are existing. This occurs as the result<br />
of update operations that are not updating the<br />
same data s<strong>to</strong>red at different places.<br />
• Example: Address Information of a cus<strong>to</strong>mer<br />
is recorded differently in different files.<br />
Disadvantages of File Processing System (cont..)<br />
• Difficulty in Accessing Data: It is not easy <strong>to</strong><br />
retrieve information using a conventional file<br />
processing system. Convenient and efficient<br />
information retrieval is almost impossible using<br />
conventional file processing system.<br />
• Data Isolation: Data are scattered in various files,<br />
and the files may be in different format, writing new<br />
application program <strong>to</strong> retrieve data is difficult.<br />
11<br />
12<br />
3
Disadvantages of File Processing System (cont..)<br />
• Integrity Problems: The data values may need <strong>to</strong><br />
satisfy some integrity constraints. For example the<br />
balance field Value must be grater than 5000. We<br />
have <strong>to</strong> handle this through program code in file<br />
processing systems. But in database we can declare<br />
the integrity constraints along with definition itself.<br />
• A<strong>to</strong>micity Problem: It is difficult <strong>to</strong> ensure a<strong>to</strong>micity<br />
in file processing system.<br />
• Example: transferring $100 from Account A <strong>to</strong><br />
account B. If a failure occurs during execution<br />
there could be situation like $100 is deducted from<br />
Account A and not credited in Account B.<br />
13<br />
Disadvantages of File Processing System (cont..)<br />
• Concurrent Access anomalies: If multiple users<br />
are updating the same data simultaneously it will<br />
result in inconsistent data state. In file processing<br />
system it is very difficult <strong>to</strong> handle this using program<br />
code. This results in concurrent access anomalies.<br />
Security Problems: Enforcing Security Constraints<br />
in file processing system is very difficult as the<br />
application programs are added <strong>to</strong> the system in an<br />
ad-hoc manner.<br />
• <strong>Database</strong> systems offer solutions <strong>to</strong> all the above<br />
problems.<br />
14<br />
The <strong>Database</strong> Approach<br />
Advantages of using a <strong>Database</strong> Approach<br />
General<br />
Ledger<br />
Production<br />
Planning<br />
Invoicing<br />
Despatch<br />
Personnel<br />
Payroll<br />
Inven<strong>to</strong>ry<br />
Order<br />
Entry<br />
• Flexible Data Access: <strong>Database</strong> Management Systems<br />
have various <strong>to</strong>ols <strong>to</strong> manipulate, query, or report data,<br />
such as Structured Query Language (SQL), and Report<br />
Genera<strong>to</strong>rs. Hence:<br />
• Selected data is easily retrieved<br />
• A DBMS can contain different data views for different<br />
users<br />
• Improved Data Integrity: Modern DBMS consist of<br />
various <strong>to</strong>ols and methods <strong>to</strong>:<br />
• ensure that data is correct, consistent, and current<br />
• verify data input and check whether data is<br />
„reasonable‟.<br />
15<br />
16<br />
4
Advantages of <strong>Database</strong> (Cont…)<br />
• Improved Data Security: Tools such as password access, and<br />
encryption, ensure that data is not:<br />
• deliberately or accidentally damaged or changed<br />
• accessed without proper authorisation<br />
• Data Independence<br />
• Problems occurs from the interdependence of data and<br />
programs are kept <strong>to</strong> a minimum.<br />
• Reduced Data Redundancy<br />
• Efficient data s<strong>to</strong>rage.<br />
• Relational <strong>Database</strong>s use Normalisation <strong>to</strong> reduce data<br />
redundancy.<br />
Advantages of <strong>Database</strong> (Cont…)<br />
• Ability <strong>to</strong> Share and Relate Data<br />
• Different user groups can use the same data.<br />
• Data in different (physical or logical) parts of the system can<br />
be related for a certain application.<br />
• Increased Productivity<br />
• Centralized Control<br />
• Enhancement of Data Quality<br />
17<br />
18<br />
Costs of <strong>Database</strong> Approach<br />
Levels of Abstraction<br />
The implementation and use of DBMS is normally<br />
associated with various costs. Such as:<br />
• Initial expenses involve planning costs, and<br />
consultancy fees.<br />
• Computer hardware costs.<br />
• Software costs.<br />
• <strong>Database</strong> Administra<strong>to</strong>r costs, and staff training<br />
costs.<br />
• Conversion costs of an existing system.<br />
• Various operational costs.<br />
There are three levels of<br />
abstraction for database<br />
design:<br />
1. Physical or Internal level<br />
2. Logical or Conceptual level<br />
3. View or External or User<br />
level<br />
View 1 View 2 View 3<br />
Logical level<br />
Physical level<br />
19<br />
20<br />
5
Levels of Abstraction (cont…)<br />
1. Physical or Internal level<br />
The lowest level of abstraction describes how the data are actually<br />
s<strong>to</strong>red. Complex low-level data structures and access methods<br />
are described in detail.<br />
2. Logical or Conceptual level<br />
The middle level describes what data are s<strong>to</strong>red in the database,<br />
and what relationships exist among those data. The entire<br />
database is described in terms of a small number of relatively<br />
simple structures.<br />
3. View or External or User level<br />
The highest level of abstraction describes only part of the entire<br />
database of concern <strong>to</strong> a user or application program. application<br />
programs hide details of data types. Views can also hide<br />
information (e.g., salary) for security purposes.<br />
The system may provide many views for the same database.<br />
21<br />
• Conceptual schema:<br />
Example: University <strong>Database</strong><br />
• Students(sid: string, name: string,<br />
login: string, age: integer, gpa:real)<br />
• Courses(cid: string, cname:string,<br />
credits:integer)<br />
• Enrolled(sid:string, cid:string,<br />
grade:string)<br />
• External Schema (View):<br />
• Course_info(cid:string,enrollment:integer)<br />
• Physical schema:<br />
• Relations s<strong>to</strong>red as unordered files.<br />
• Index on first column of Students.<br />
View 1 View 2 View 3<br />
Conceptual Schema<br />
Physical Schema<br />
DB<br />
22<br />
• Instance<br />
Instances and Schemas<br />
<strong>Database</strong> change over time as information is<br />
inserted and deleted. The collection of information<br />
s<strong>to</strong>red in the database at a particular moment is<br />
called an instance of the database.<br />
[<br />
• Schema<br />
The overall design of the database is called the<br />
database schema.<br />
<strong>Database</strong> systems have several schemas,<br />
partitioned according <strong>to</strong> the levels of abstraction. At<br />
the lowest level is the physical schema; at the<br />
intermediate level is the logical schema; at the<br />
highest level is the subschema.<br />
23<br />
Data Models<br />
A data model is a collection of concepts for<br />
describing data and data relationships.<br />
•Entity-Relationship model<br />
•[<br />
•Relational model<br />
•Other models:<br />
object-oriented model<br />
semi-structured data models (XML)<br />
Older models: network model and hierarchical<br />
model<br />
24<br />
6
Entity Relationship Model<br />
Models an enterprise as a collection of entities and<br />
relationships.<br />
Entity: a “thing” or “object” in the enterprise that is<br />
distinguishable from other objects. Described by a set of<br />
attributes.<br />
Relationship: an association among several entities.<br />
Relational Model<br />
The relational model uses a collection of tables <strong>to</strong> represent<br />
both data and the relationships among those data.<br />
Each table has multiple columns, and each column has a<br />
unique name.<br />
teacherID<br />
name<br />
courseNo<br />
title<br />
teacher<br />
conduct<br />
course<br />
25<br />
26<br />
Object oriented Data Model<br />
• Current generation systems have a need <strong>to</strong> handle<br />
<strong>com</strong>plex data for <strong>com</strong>plex applications such as -<br />
• <strong>com</strong>puter aided design<br />
• <strong>com</strong>puter aided software engineering<br />
• geographic information systems<br />
• interactive web sites<br />
• Object oriented databases are well suited <strong>to</strong><br />
handling graphics based or multimedia applications.<br />
Can S<strong>to</strong>res objects (documents, multimedia, Image,<br />
Video).<br />
Semi-structured data models -<br />
Extensible Markup Language (XML)<br />
• Defined by the WWW Consortium (W3C)<br />
• Originally intended as a document markup<br />
language not a database language.<br />
• The ability <strong>to</strong> specify new tags, and <strong>to</strong> create<br />
nested tag structures made XML a great way <strong>to</strong><br />
exchange data, not just documents.<br />
• XML has be<strong>com</strong>e the basis for all new generation<br />
data interchange formats.<br />
• A wide variety of <strong>to</strong>ols is available for parsing,<br />
browsing and querying XML documents/data.<br />
27<br />
28<br />
7
Hierarchical Model<br />
• S<strong>to</strong>res data as hierarchically related <strong>to</strong> each other.<br />
Record shape are tree structure.<br />
• Logically represented by an upside down tree<br />
• Each parent can have many children<br />
• Each child has only one parent<br />
NUB<br />
Network Model<br />
A network database is similar <strong>to</strong> hierarchical DBMS, but<br />
each child record can have more than one parent record.<br />
Thus a child record may be reached through more than one<br />
parent.<br />
University class scheduling system<br />
CIT 1101 CIT 3303 MIS 4102<br />
Faculty of<br />
Science<br />
Faculty of<br />
Business<br />
SMR BA ZH<br />
CSE<br />
CS<br />
BBA<br />
MBA<br />
Student 1 Student 2 Student 3 Student 4 Student 5<br />
29<br />
30<br />
DBMS Languages<br />
• Data-Definition Language (DDL) : DDL concerned<br />
with defining the structure of the database.<br />
• Data-Manipulation Language (DML): DML<br />
concerned with querying and manipulating the data<br />
in the database. They are basically two types:<br />
• Procedural DMLs: Procedural DMLs require a<br />
user <strong>to</strong> specify what data are needed and how <strong>to</strong><br />
get those data.<br />
• Nonprocedural DMLs: Nonprocedural DMLs<br />
require a user <strong>to</strong> specify what data are needed<br />
without specifying how <strong>to</strong> get those data.<br />
Goals of <strong>Database</strong> Design<br />
It is important <strong>to</strong> design the database in such a way<br />
that:<br />
• A specific item can be reached easily<br />
(maximum guarantee that the desired record will be reached)<br />
• The database can respond <strong>to</strong> the user’s different questions<br />
easily (necessary relationships are provided)<br />
• The database occupies minimum s<strong>to</strong>rage space (choosing<br />
data types and how <strong>to</strong> express a certain concept is important)<br />
• The database contains no unnecessary data<br />
(s<strong>to</strong>ring the gross salary is enough, the net salary can be<br />
calculated from the gross salary)<br />
• Data can be added and updated easily<br />
without causing mistakes (no data redundancy)<br />
31<br />
32<br />
8
Steps in <strong>Database</strong> Design<br />
• Requirement analysis<br />
What does the user want<br />
• Conceptual database design<br />
Defining the entities and attributes, and the<br />
relationships between these --> The ER model<br />
• Physical database design<br />
Implementation of the conceptual design using a<br />
<strong>Database</strong> Management System<br />
Any Question<br />
<br />
33<br />
34<br />
Thanks <strong>to</strong> All<br />
35<br />
9