week 3
week 3
Personnel Finance
Employees Accounts
Sales
Finance
Database Concepts
• Advantages of a database system
• Data is at the centre
• Data is maintained independently of the applications that access it
• Centralised maintenance and utilities can be employed
• A database must contain descriptions of the data it holds
• This is the schema and it is the definition of the record structure within the
database
• It provides a way to logically group objects such as tables, views, stored
procedures etc.
Database Management Systems (DBMS)
• A collection of programs that manage the database structure and
control access to the data.
• Provide a way to share data between multiple users and / or
applications.
• Makes the management of data more efficient and effective.
DBMS Application Application Application
Online Users
Online Users
Online Users
DBMS
Maintenance
& Utilities
Database
Schema
Role of the DBMS
User 1
Meta Data
DBMS Customer
Invoice
User 2
Product
DBMS - Functions
• Access to the data and the schema is provided by the DBMS.
• Schema is stored in the database itself.
• Data stores it’s own description
• Different modes of access available
• High level language – SQL
• Via a user interface – for example web front end
DBMS Advantages
• Data can be managed easier
• Users can be provided with improved access to the data
• Provides an integrated view of an enterprises operations
• The risk of inconsistent data is greatly removed
Database Types
• Single User System
• A system running on a single machine such as a desktop
• Multi User System
• Multiple users at a time. Could be a database for a department
• Enterprise System
• Multi user system that can support a large group of users, a number of
departments or an entire organisation
Database Classification
• Location
• Centralised
• Distributed
• Use
• Transaction based
• A standard database used to support a company in its everyday business
• Data warehouse
• Used for analysis rather than processing transactions
• Used to store historical data
• Schema looks very different
Requirements
• All users should be able to access all the data
• Within the limits set by the database administrator (DBA)
• A user does not need to know anything about the way that the data is
stored
• Changes to the structure of the database must be able to be made
without affecting users
• Data independence - internal structure of database should be
unaffected by changes to physical aspects of storage
Three Level Architecture
• Most relational databases are loosely based on the ANSI-SPARC
architecture
• ANSI - American National Standards Institute
• SPARC - Standards Planning And Requirements Committee
• This is a non standard standard!
• Identifies 3 levels
• External level
• Conceptual level
• Internal level
ANSI SPARC
External Level User View 1 User View 2 User View 3
Conceptual
Conceptual Level Schema
Physical Data
Organisation Database
ANSI SPARC 3 Levels
• External Level
• A users’ view of the database
• Describes the database section that is relevant to a particular user
• Conceptual Level
• A global view of the database
• Describes what data is stored and stores the relationships between the data
• Independent of both hardware and software
• Internal Level
• Physical representation of the database
• Describes how the data is actually stored in the database
ANSI SPARC Levels
External View 1 External View 2
External Level
staff_id f_name l_name dob salary staff_id l_name branch_id
Conceptual
staff_id f_name l_name dob salary branch_id
Level
struct staff {
int staff_id;
int branch_id;
varChar f_name [15];
varChar l_name[15];
Internal Level struct date dob;
decimal salary;
struct STAFF *next;
};
index staff_id ; branch_id;
Data Independence
• We are separating the application from the data
• This means that any changes made to the way we access the data or
store the data will not affect the application
Data Independence
Physical Data
Organisation Database
Data Independence
• Logical Data Independence
• Refers to immunity of external schemas to changes in conceptual schema.
• Conceptual schema changes (e.g. addition/removal of entities).
• Should not require changes to external schema or rewrites of application
programs.
• Physical Data Independence
• Refers to immunity of conceptual schema to changes in the internal
schema.
• Internal schema changes (e.g. using different file organisations, storage
structures/devices).
• Should not require change to conceptual or external schemas.
Database Language
• SQL is made up of two main types of language
• Data Definition Language
• Allows DBA or users to describe and name entities, attributes, and
relationships required for the application, and associated integrity and
security constraints.
• Data Manipulation Language
• Provides the ability to manipulate data within the database.
DDL
• Commands that define the structure of the database.
• They can remove, create & modify database objects such as tables,
users and indexes.
• The most commonly use DDL commands are
ALTER TABLE
CREATE DATABASE
CREATE TABLE
DROP DATABASE
DROP TABLE
RENAME TABLE
DDL
create table property_for_rent (
Property_id varchar(4) PRIMARY KEY,
Street varchar(14) not null,
City varchar(10) not null,
Postcode varchar(10) not null,
Type varchar(6) not null,
Rooms integer not null,
Rent decimal(6,2) not null,
Owner_id varchar(4) not null REFERENCES
private_owner(owner_id),
Staff_id varchar(4) REFERENCES staff(Staff_id),
branch_id varchar(4) REFERENCES branch(Branch_id)
);
DML
• Data manipulation language commands are used for selecting,
inserting, deleting and updating data in a database.
DELETE
INSERT
REPLACE
SELECT
UPDATE
DML
select property_id,
street,
city,
postcode,
owner_id from property_for_rent
where city = ‘Glasgow’;
Database Development
• Database development lifecycle
• The database is an essential component of an organisation’s information system
(IS).
• To be effective, an information system requires a structured approach to the
design and development, which usually comprises the following stages:
• Planning
• Requirements collection
• Analysis
• Design (including database design)
• Prototyping
• Implementation
• Testing
• Conversion
• Operational maintenance
Database Development
• Database development lifecycle
• As a fundamental part of the organisation-wide IS, the database system
development lifecycle is inherently linked with the IS lifecycle.
• The database project will commence with the creation of a mission
statement including the objectives for the database system, i.e.:
• The mission statement defines the major aims of the database system
• Each mission objective identifies a particular task that the database must
support.
• Planning the development process must include some estimation of the
work required and the resources available.
• Thank you