Download Database Introduction

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Extensible Storage Engine wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
And Franchise Colleges
HSQ - DATABASES & SQL
Supplement 01a
Database-Introduction-1
By MANSHA NAWAZ
Supplement 01 (a)
Database-Introduction-1
Why Database Systems?
• Data is one of the most important resources in ALL
organisations. Without data it is not possible to operate.
•
•
•
•
•
Control manufacturing processes?
Process sales of goods?
Diagnose patients’ illnesses?
Forecast sales?
Run the University of Teesside?
• To be useful data must be processed into information. It must
be:
• Accurate
• Timely
• Relevant
• Therefore, you need adequate facilities for storing data and
processing information:
– Storing (and verifying) data
– Manipulating data
– Extracting data
Supplement 01 (a)
Database-Introduction-1
File - based approach
•
•
•
From the earliest days computers were used to store files of data.
Separate systems, ie separate files and programs, were developed for each
application, eg stock files, production files, accounts files, etc.
Applications processed the data to provide information.
Data
Application
Department
Part No, Supplier, qty
location, reorder qty
Stock Control
Stores
Part#, qty, Assy#,
Machine#, Cert.#:
Production
Operations
Supplier, Part#, Part#,
Cost, Qty
Accounts
Finance
Supplement 01 (a)
Database-Introduction-1
Problems
Inconsistency
Redundancy
Lack of integration
Lack of control
Database approach
•
•
•
DBMS is the environment used to manage a database
The database consisting of stored data and processed information for a system
Data are organised into a single set of underlying TABLES from which the
applications draw the data to provide information that are relevant to them.
Department
Application
Stock Control
Production
Accounts
Supplement 01 (a)
Database
Database
Management
System
DBMS
Database-Introduction-1
Supplier, Supplier Pt No:,
Part No:
Cost, Qty ordered, Qty
del., qty, Assy No:,
Machine No:, Cert. No:
location, reorder qty
Database Development
Systems Analysis & Design
DFD DataStores, DataFlows and Data Dictionary
DATA MODEL
TABLE SET
E-R Model
NF
DBMS
PHYSICAL VIEW OF DATA
LOGICAL VIEW OF DATA
TABLES
FORMS
Database connectivity via
websites
www .net technology
Macromedia Dreamweaver
MS Visual Studio
Supplement 01 (a)
Database connectivity via
desktop DBMS such as
MS Access
Database connectivity
via programming
languages such as MS
Visual Basic
Database-Introduction-1
Area of Interest
Client/Server Architecture
•
•
•
Server provides services for the Clients which are responsible for interacting with the users
(Input/Output)
Server is responsible for performing a service (e.g. transaction) and guaranteeing the
integrity of the data
Well suited for distributed systems handling large amounts of data
User Workstation
Department
File-Servers
Corporate
Servers
User Workstation
Operator
Workstation
Supplement 01 (a)
Database-Introduction-1
System Development Overview
•
•
•
•
•
Systems development undertaken by using Case Tools
– used early in development life cycle
– Provide requirements and design in terms of Systems Model and Data Model
Case Tools for Systems Modelling:
– Dataflow Diagrams (DFD)
– Data Dictionary (DD)
Case Tools for Data Modelling:
– Normalisation (NF)
– A rules based technique undertaken to produce the data model for a system
– Entity Relationship Model (ER)
– A diagrammatic based technique undertaken to produce the data model for a system
– DFD & DD provide us with the base for a ERD Data Model
Data Model
– Can be implemented on a DBMS such as MS SQL Server, MS Access, etc
– Consists of logical and physical view of the proposed systems data.
DBMS – implementation platform
– Database Management System such as MS SQL Server 2000 (MS Access)
Supplement 01 (a)
Database-Introduction-1
MS SQL Server
V
MS Access
•
MS Access is
Desktop based
•
Small, low-traffic
database
systems
•
MS SQL Server is a server based database.
•
Multi User – Multi Platform Systems
•
Large, high volume traffic database systems
•
Server holds database. Workstation provides access.
•
For web or database systems if the access traffic is likely to
generate more than 20 concurrent database hits at a time,
•
it's time to move to a database server
•
Generally, database servers like MS SQL Server are the way
to go for database or web/database systems
•
Many and wide ranging user base for system
•
Additional Security and Login features
•
MySQL (free sql database used for connectivity to Websites via PHP).
Supplement 01 (a)
Database-Introduction-1
•
Small, low-traffic
web sites
requiring
database
connectivity.
Cannot handle
heavy traffic from
multiple users.
Advantages of the Database Approach
•
•
•
•
•
•
•
•
No unnecessary duplication of data.
Greater consistency of data.
Wider availability of data.
Greater flexibility of use of data.
Improved data integrity.
Improved security.
Improved backup and recovery services.
Can change the data structure without altering associated
programs.
• A database is dynamic: it can grow and change.
• Data management can be more consistent and systematic.
Supplement 01 (a)
Database-Introduction-1
Databases
• “A shared collection of logically related data, and a
description of this data, designed to meet the information
needs of an organisation.”
‘Database Systems’ by Connolly & Begg Addison-Wesley, ISBN 0-201-70857-4
• “A database system can be thought of as a computerised
record-keeping system. Such a system involves the data
itself (stored in the database), hardware, software and – most
important! – users.
• … Databases are integrated and (usually) shared; they are
used to store persistent data.”
‘An Introduction to Database Systems’ by C J Date, Addison-Wesley, ISBN 0-20138590-2 (7th Edition, 2000)
Supplement 01 (a)
Database-Introduction-1
DBMS
• “A software system that enables users to define, create,
maintain, and control access to the database.”
• Provides the interface between the user and the data in the
database.
• Allocates storage to data and maintains indices so that any
required data can be retrieved.
• Protects data against unauthorised access.
• Safeguards data against corruption.
• Provides recovery and restart facilities after a hardware or
software failure.
Supplement 01 (a)
Database-Introduction-1
Data Model
• Also referred to as Conceptual Model
– A Data Model provides a particular way of thinking about data, at least in terms of its structure
– Data Models include data descriptions, data relationships, data semantics, consistency
constraints [Silberschatz et. al.]
– Data model comprises three components: data structures, data manipulators, and general
integrity rules [Codd (1970)]
• A Data Model is implementation independent
– Not aimed at any particular computer software or hardware.
• DBMS supports an implementation of one or more Data Models
– What data model is supported by a Relational Database Management System
(Access, SQL, Oracle, etc.)
– A RDBMS may have extensions to support other models.
• At what stage in the Systems Development Lifecycle will data
modelling take place (early, middle, late)?
Supplement 01 (a)
Database-Introduction-1
Data Model
– Data Models produced early in Systems Development
– Makes improvements in terms of :
• NO DUPLICATION or REDUNDANT or NULL INFORMATION
• REDUCTION IN PHYSICAL SIZE
• QUICKER INFORMATION RETRIVAL
• LEADS TO A FULLY OPTIMISED SET OF TABLES
– Data Model produced by Case Tools techniques
• Normalisation
– Rule based technique for transfering logical datastore view to physical view
• Entity Relationship Modelling.
– Diagrammatic representation of a proposed systems database requirements
– Data Model provides
• a full set of related tables and data
• Able to derive physical views (internal schema) of data
• Able to derive logical views (external schema) of data
Supplement 01 (a)
Database-Introduction-1
Normalisation (NF)
• Provide us with a Bottom Up approach to producing the database tables
• Technique covered in other modules
• Supplement on Normalisation is provided on the DD website
Entity Relationship Modelling (ERM)
•
•
•
•
•
•
A data modelling CASE Tool Technique of interest
A diagrammatic representation of a systems database tables
Top Down approach to data modelling
Entity Relationship Diagram (ERD) used to map data model
Applying rules, translate ERD into a set of well-normalised tables
Provides both logical and physical view of tables
Supplement 01 (a)
Database-Introduction-1
PHYSICAL VIEW
–
–
–
–
–
–
–
–
TABLES
DATA
Internal Schema View
database structure view that a DBMS requires.
in terms of Tables, Attributes (data fields) and Types (data defn.)
linkage between tables via primary and foreign keys
All Datastores decomposed to a set of TABLES
Physical View – for Designers
LOGICAL VIEW
–
–
–
–
–
–
FORMS
INFORMATION
External Schema View
Form or Screen views provided to the end user.
A set of FORMS derived from the TABLES
Logical View – for Users
Supplement 01 (a)
Database-Introduction-1
The Three Level ANSI-SPARC Architecture
• In 1975 the ANSI Standards Planning and Requirements Committee
proposed a standard terminology and general architecture for database
systems.
• The objective is to separate each user’s view of the database from the
way it is physically represented. 3 levels or views of data within a
database:
• External Level
– The users’ view of the database. Also known as the applications view.
• Conceptual Level
– The overall view of the database. Also known as the global view.
• Internal Level
– The physical representation of the database on the computer. Also known
as the storage view.
Supplement 01 (a)
Database-Introduction-1
Schemas
• The overall description of the database is called the database
schema. There are 3 different types of schema in the database.
• External Schema
– There are multiple external schemas (or subschemas), each one
corresponding to a different view of the data.
• Conceptual Schema
– There is one conceptual schema, which describes the data stored in
the database, the relationships and the integrity constraints.
• Internal Schema
– There is one internal schema, which describes how the data are stored
in the database and how they are accessed.
Supplement 01 (a)
Database-Introduction-1
Schemas and Views
Conceptual
Customer
Service
Finance
Inventory
Production
External
HR
Internal
External
Supplement 01 (a)
Database-Introduction-1
Mapping
•
•
•
Provides the translation between the schemas at different levels. The DBMS is responsible
for mapping between the 3 types of schema.
The DBMS must ensure that each external schema is derivable from the conceptual schema.
The DBMS must use the information in the conceptual schema to map between each
external schema and the internal schema.
Supplement 01 (a)
Database-Introduction-1
Data Independence
• A major objective for the 3-level architecture is to provide data
independence, ie upper levels must be unaffected by changes to lower
levels.
• There are 2 kinds of data independence:
• Logical data independence
– refers to the immunity of the external schemas to changes in the
conceptual schema.
– It should be possible to alter tables, columns or relationships without
having to alter existing external schemas or rewrite application programs
(other than those that are directly affected).
• Physical data independence
– refers to the immunity of the conceptual schema to changes in the internal
schema.
– It should be possible to alter file organizations, storage devices, indexes,
etc, without having to alter the conceptual or external schemas.
Supplement 01 (a)
Database-Introduction-1
The Systems Catalogue
• The database schema is defined using a special language called
a Data Definition Language (DDL).
• The result of the compilation of the DDL statements is a set of
tables stored in special files collectively called the system catalog.
• This is a repository of meta-data (data about data), ie information
describing the data in the database, typically containing the name,
description, source and usage information for each data item.
• The system catalog is also known as the data dictionary or the
data directory.
Supplement 01 (a)
Database-Introduction-1
Database Language
• A Data Definition Language (DDL) is used to specify the data in the
database.
• A Data Manipulation Language (DML) is used to access the data.
• A Data Control Language (DCL) is used to control access to the data.
• Some databases have a combined DDL, DML and DCL (often called a
Query Language), eg SQL.
Supplement 01 (a)
Database-Introduction-1
Database Types - 3 Main Data Models
• Each database uses a definition language
– imposes restrictions on
• what can be defined
• how entities relate to each other
Hierarchical model
Network model
Supplement 01 (a)
Relational model
Database-Introduction-1
Database Types - Network
Can show all 1:n relationships between records
Supplier Name
Link File
Supplier Part No:
Part No:
Supplement 01 (a)
Database-Introduction-1
Database Types - Hierarchical
STOCK
Electrical
Steel
Oils
Fasteners
Part No:
Quantity
Supplier Name
Supplier Code
Supplement 01 (a)
Supplier Part No:
Database-Introduction-1
Location
Database Types - Relational
Data Files
FILE
RECORD
FIELD(S)
FIELD
VALUES
KEY
FIELD
PRIMARY
KEY
Supplement 01 (a)
STOCK
ITEM
STOCK
ITEM
STOCK
ITEM
STOCK ITEM
Part No: 12345
Colour
N/A
Weight
98
Location F37
Quantity
Reorder Qty
7
4
Supplier Name Ferris
Supplier Code F2
Description
Supplier Part No: c801
Cadmium Bar 90mm dia
Database-Introduction-1
Database Types - Relational
Logical vs. Physical
STOCK
ITEM
STOCK
STOCKITEM
ITEM
LOGICAL
Part No: 12345
FIELD(S)
Colour
N/A
FIELD
VALUES
Weight
98
PHYSICAL
Supplement 01 (a)
Quantity
Reorder Qty
Location F37
7
4
Supplier Name Ferris
Supplier Code F2
Description
Supplier Part No: c801
Cadmium Bar 90mm dia
Database-Introduction-1
Relationships - 1:1
STOCK
ITEM
STOCK
ITEM
STOCK ITEM
Part No: 12345
Colour
N/A
Weight
98
Location F37
Quantity
Reorder Qty
7
4
Supplier Name Ferris
Supplier Code F2
Description
Supplier Part No: c801
Cadmium Bar 90mm dia
Supplement 01 (a)
Database-Introduction-1
Relationships - 1:n
STOCK
ITEM
STOCK
STOCKITEM
ITEM
Part No: 12345
Colour
N/A
Weight
98
Location F37
Quantity
Reorder Qty
7
4
Supplier Name Ferris
Supplier Code F2
Description
Supplier Part No: c801
Cadmium Bar 90mm dia
Supplement 01 (a)
Database-Introduction-1
Relationships - m:n
STOCK
ITEM
STOCK
STOCKITEM
ITEM
Part No: 12345
Colour
N/A
Weight
98
Location F37
Quantity
Reorder Qty
7
4
Supplier Name Ferris
Supplier Code F2
Description
Supplier Part No: c801
Cadmium Bar 90mm dia
Supplement 01 (a)
Database-Introduction-1
Relational Model Technique
Future Lectures will cover the
Entity Relationship Diagrams (ERD’s)
Supplement 01 (a)
Database-Introduction-1