Introduction Part 2
Introduction Part 2
Development
• Informally:
– a database is a collection of related data
– a database management system (DBMS) is the
software that provides the functionality to manage
and access a database
– a database contains data integrated from several
sources (e.g. departments of a company)
– data is available in a standard format for many
different applications
What is a database?
Any collection of data can be described as a
database
Computerised database systems are now very
commonplace
Information is stored in a database every time
we:
use a bank account
book a travel ticket
make an appointment with a doctor
etc.
Basic Definitions
Database:
A collection of related data.
Data:
Known facts that can be recorded and have an implicit meaning.
Mini-world:
Some part of the real world about which data is stored in a database. For
example, student grades and transcripts at a university.
Database Management System (DBMS):
A software package/ system to facilitate the creation and maintenance of a
computerized database.
Database System:
The DBMS software together with the data itself. Sometimes, the applications
are also included.
Why databases?
• To avoid:
– redundant data
– redundant processes/interfaces
• To enable:
– ease of maintenance
– sharing of data
data instructions
.
. . . . .
metadata
applic. pgm. n
.
instructions
• DBMS is “general purpose”
• self-describing
• contains data + metadata (“data about data”)
.
Example of the Database
Approach : a library system
DATABASE
APPLIC 1
Books
DBMS APPLIC 2
Borrowers
APPLIC 3
Loans
.
.
.
What is a DBMS?
Users/Programmers
DATABASE
SYSTEM Application Programs/Queries
DBMS
SOFTWARE Software to Process
Queries/Programs
Software to Access
Stored Data
• data is:
– integrated, shared, persistent
– self-describing
• abstraction: program-data
independence
• multiple views of the data
(different users need different kinds of
information)
Advantages of the database approach
– controlled redundancy
– data consistency and integrity
– sharing of data (multiple users)
– re-use of data across multiple applications
– improved security
– enforcement of standards and computation of
statistics
– economy of scale
– improved responsiveness, productivity
– DBMS provides: backup/recovery, concurrency
• complexity
• size (of software and application)
• cost
• performance
• risk of (spectacular!) failures
Relational databases
Relatively complex data like this is better handled with the
relational model
Devised by Edgar Codd around 1970
Most databases nowadays are relational databases
although there are others: object databases, XML databases,
“NoSQL” databases
A database management system which uses the relational
model is called an RDBMS
Databases and Enterprise
Information Systems
Web pages GUI UI Layer
Command Domain
Objects Objects
Database
Desktop Application
Client
Application
network or internet
Desktop PC
connections
Server
Client Database
Desktop PC
Application
Client-Server Application
network server
Web browser
Desktop PC
Servers
Server
Enterprise Database
Web browser
Application
Desktop PC
ORDERS
ordno {p_key}
month
qty
extension of the example database (1)
CUSTOMERS
cid name city discount contact
cOO1 TipTop London 10.00 Mr Smith
cOO2 Basic Paris 12.00 M Parot
cOO3 Allied London 8.00 Ms Evans
cOO4 ACME New York 8.00
cOO6 ACME Kyoto 0.00
extension of the example database (2)
PRODUCTS
pid name city quantity price
p01 Comb London 111400 0.50
p02 Brush New York 303000 0.50
p03 Razor New York 150600 1.00
p04 Pen Paris 125300 1.00
p05 Pencil Paris 221400 1.00
p06 case London 123100 2.00
extension of the example database (3)
ORDERS
ordno month cid pid qty Relationships are
1011 Jan c001 p01 1000 implemented by
1012 Jan c002 p03 1000 placing the primary
1013 Feb c001 p05 400 key value as a
1014 Feb c002 p03 200 ‘foreign key’ in the
1015 Feb c003 p04 500 table at the ‘many’
1016 Mar c001 p02 100 end
Designing a database
0..*
Package 1..1
-location
-name Tour
-description -departuredate
-adultprice -offer
-childprice 1..1 0..*
-departure
Data models
business layer
for example as Java classes and objects
business logic in Java methods
database layer
data is stored permanently in a database
system queries database to get data it needs to carry out a
particular action
The system needs to map data from database tables to
classes
Data modelling
Day
Student
CAR
• properties of relationships:
– cardinality
•degree – 1:1, 1:N, N:M
•participation constraints – mandatory, optional
Relationships (2)
Person Car
• entities
• attributes
• cardinalities and participation constraints of the relationship
Generalization / specialization (1)
– disjoint/overlapping constraints:
•disjoint:
an instance of a superclass may be a
member of only one subclass (or)
•overlapping: an instance of a superclass may be a
member of more than one subclass (and)
Graphical notation for generalisation/ specialisation
hierarchies (1)
Student
P/G
• they are inherited by the subclasses U/G
degree
res_topic
tutor
supervisor
Sports_Members
{Optional, And}
• Conceptual design
– high level; independent of DBMS type
– described by a conceptual model
• Logical design
– description of structure of database; depends on DBMS type
– described by a logical model
• Physical design
– description of implementation of the database in terms of
storage structures and access methods
– DBMS specific; described by a physical model
Roles in the Database Environment
• database administrators: DBAs
– oversee, manage resources
– authorisation
– security policy
– performance, tuning ….
• database designers
– identify data to be stored and structure to be used, identify
constraints
– design includes structural and functional aspects
• application programmers
– develop and implement end-user requirements
• end users
– may be sophisticated/naïve, regular/casual ...
Database Languages
• DBMS support different users performing a range of
tasks; so appropriate languages and interfaces are
required:
– Data Definition Language (DDL)
– includes structure and view definition languages
– Data Manipulation Language (DML)
– high or low level (declarative or procedural)
– standalone or embedded in a host procedural language
– set-oriented or record-oriented