Lecture 1
Lecture 1
Databases
Prof. KOLIECHKINA LIUDMYLA
Faculty of Mathematics and Computer Science
Department of Algorithms and Database
E-mail:
[email protected]
Where can you get these programs?
Oracle XE (11)
https://www.oracle.com/technetwork/database/database-
technologies/express-edition/downloads/xe-prior-releases-5172097.html
You can work online (you need to create an account)(Oracle Live SQL)
https://livesql.oracle.com/apex/f?p=590:1000
Course Content:
1. Overview of database systems, data models, query
languages.
2. Relational model and relational algebra.
3. Oracle Database Management System.
4. Oracle database objects (tables, integrity constraints,
indexes, views, sequences).
5. Oracle SQL Data Definition Language.
6. Common conceptual and implementation data models.
7. Designing of database system:
1) Entity-Relationship Diagrams; 2) Data normalization issues.
8. Transforming ER model into a relational database schema.
9. Oracle SQL Data Manipulation Language.
10. Introduction to PL/SQL (functions, procedures, triggers, cursors).
3
Topics of lectures
1. Introduction to database. Database
Modeling (ERD Entity Relationship
Diagrams). Normalization. (Lectures 1-2)
2. SQL database language – basics.
SQL Data Definition. Oracle Data Modeler
(Lectures 3-4)
3. Selected relational Oracle database objects
(tables, views, constraints, indexes,
sequences) and can be created using Oracle
SQL dialect (Lectures 5, 6, 7)
4
Topics of lectures
4. Data Definition Language - DDL
Data manipulation Language - DML
DQL query Language - SELECT
statement (Lectures 7, 8)
5. Creature basic PL/SQL procedures
Creature basic PL/SQL functions
Creature basic PL/SQL triggers
(Lectures 8-14)
5
Lecture 1
Introduction to database
6
Lecture outline
1. Basic database information
2. Basic concepts and definitions
3. Database schema
4. Entity/Relationship Modelling
5. Relationships and Diagramming
Relationships
7
What is a Database?
A database is simply a collection of
organized information, usually as a set of
related lists of similar entries.
The data is often organized so that it is
easily accessible.
The following are examples of
databases that we use often:
– address book;
– dictionary;
– telephone book.
8
Database
9
Well-known DBMSs include
MySQL, PostgreSQL, MongoDB,
MariaDB, Microsoft SQL Server,
Oracle, Sybase, SAP HANA,
MemSQL, SQLite and IBM DB2.
10
2. Basic concepts and
definitions/1
Information
Data
Table, columns, and rows
Data types
11
2. Basic concepts and
definitions/2
Information is stimuli that has
meaning in some context for its
receiver.
When information is entered into and
stored in a computer, it is generally
referred to as data.
After processing (such as formatting
and printing), output data can again
be perceived as information.
12
The concept of data is
commonly associated with
scientific research, data is collected by a
large range of organizations and
institutions, including businesses (e.g.,
sales data, revenue, profits, stock price),
governments (e.g., crime rates,
unemployment rates, literacy rates) and
non-governmental organizations (e.g.,
censuses of the number of homeless
people by non-profit organizations).
13
A table is a collection of related data held
in a structured format within a database.
It consists of columns, and rows.
In relational databases, and flat file
databases, a table is a set of data
elements (values) using a model of
vertical columns (identifiable by name)
and horizontal rows, the cell being the
unit where a row and column intersect.
14
15
Database Concepts
Database – a collection of related tables.
Tables – a collection of related records
– collection of related entities.
Record – collection of fields (table row)
–represents an entity.
Field – collection of characters (table
column) – represents an attribute.
Character – single alphabetic, numeric or
other symbol.
16
Simple data types
Data Type Used for Example
String Alphanumeric hello world,
characters Alice,Bob123
Integer Whole numbers 7, 12, 999
Float Number with a decimal point 3.15, 9.06, 00.13
(floating point)
Character Encoding text numerically 97 (in ASCII, 97
is a lower case 'a')
Boolean Representing logical values TRUE, FALSE
17
Data types in tables
BYTE data type Stores any kind of binary data, up to 231
bytes in length
CHAR(n) data type Stores character strings; collation is in
code-set order
CHARACTER(n) data type Is a synonym for CHAR
CHARACTER VARYING(m,r) data type Stores character
strings of varying length (ANSI-compliant); collation is in code-
set order
DATE type Stores calendar dates DATETIME data type Stores
calendar date combined with time of day DEC data type Is a
synonym for DECIMAL
DECIMAL Stores floating-point numbers with definable
precision; if database is ANSI-compliant, the scale is zero
18
3. Database schema
19
The term "schema" refers to the
organization of data as a blueprint of
how the database is constructed
(divided into database tables in the case
of relational databases).
20
21
22
23
24
Abstract Concepts
Entity – person, place, object or
event – stored as a record or a table
row
25
4.Entity/Relationship
Modelling
Entity–relationship modeling was
developed for database design by Peter
Chen and published in 1976.
However, variants of the idea existed
previously.
Some ER modelers show super and
subtype entities connected by
generalization-specialization relationships,
and an ER model can be used also in the
specification of domain-specific ontologies.
26
Definition 1.
The Entity-Relationship (ER) model,
a high-level data model that is useful in
developing a conceptual design for a
database.
27
Entity
Definition 2
An entity is a real-world item or concept
that exists on its own. The set of all possible
values for an entity is the entity type.
Primary Key
Foreign key
Relationships
29
Primary Key
27
Foreign key
A foreign key+ (sometimes called a
referencing key) is a key used to link two
tables together.
Typically you take the primary key field
from one table and insert it into the other
table where it becomes a foreign key (it
remains a primary key in the original
table).
We can have more than one foreign key in
a table.
28
Relationships
32
Entity/Relationship Modelling
E/R Modelling is used for
conceptual design
Entities - objects or items of interest
Attributes - facts about, or
properties of, an entity
Relationships - links between
entities
33
5.Relationships and
Diagramming Relationships
Relationships are an Relationships have
association between A name
two or more entities A set of entities that
Each Student takes participate in them
several Modules A degree is the
Each Module is taught number of entities
by a Lecturer that participate (most
Each Employee works have degree 2)
for a single Department A cardinality ratio
34
Cardinality Ratios
Each entity in a relationship can
participate in zero, one, or more
than one instances of that
relationship
This leads to 3 types of
relationship…
35
One to one (1:1)
Each lecturer has his office
One to many (1:M)
A lecturer may teach many students,
but each student has just one tutor
Many to many (M:M)
Each student takes several modules,
and each module is taken by several
students
36
Recursive
Recursion (adjective: recursive) occurs when a
thing is defined in terms of itself or of its type.
EMPLOYEE
supervises
is supervised by
37
Essential elements
of the database definition
The database schema
Schema objects
Tables
Fields and columns
Records and rows
Keys
Relationships
Data types
38
Database Components
DBMS
===============
Design tools
Table Creation
Form Creation
Query Creation
Report Creation
Procedural
Application
language Programs
Database
compiler (4GL)
===========
Run time
Database contains: Form processor
User’s Data Query processor User
Metadata Report Writer Interface
Indexes Language Run time Applications
Application Metadata
39
Database Design Goes Through Stages
Problem
Requirements Analysis
Data Requirements
Data Analysis, Conceptual Design
Conceptual Schema
Logical Database Design
Logical Schema
Physical Database Design
Physical Schema
40
Conceptual and Logical Design
1.Conceptual Model;
2.Relational Model: (plus
functional dependencies);
3.Normalization.
41
Conceptual Model:
42
6. Database Management
System (DBMS)
43
You can also write your own set of
programs to create and maintain
the database, i.e. your own
Special-aim DBMS software.
Database + Software =
= Database System
44
45
46
Three-level architecture
External External External
Schema 1 Schema 2 … Schema n
External
Conceptual level
Conceptual
level Schema
Physical Internal
level Schema
47
Components of DBMS
DBMS have several components, each
performing very significant tasks in
the database management system
environment. Below is a list of
components within the database and
its environment.
48
Software
This is the set of programs used to
control and manage the overall
database. This includes the DBMS
software itself, the Operating System,
the network software being used to
share the data among users, and the
application programs used to access
data in the DBMS.
49
Hardware
Consists of a set of physical electronic
devices such as computers, I/O
devices, storage devices, etc., this
provides the interface between
computers and the real world
systems.
50
Data
DBMS exists to collect, store, process
and access data, the most important
component. The database contains
both the actual or operational data
and the metadata.
51
Procedures
These are the instructions and rules
that assist on how to use the DBMS,
and in designing and running the
database, using documented
procedures, to guide the users that
operate and manage it.
52
Database Access Language
This is used to access the data to and
from the database, to enter new data,
update existing data, or retrieve
required data from databases.
The user writes a set of appropriate
commands in a database access
language, submits these to the DBMS,
which then processes the data and
generates and displays a set of results
into a user readable form.
53
Query Processor
This transforms the user queries into
a series of low level instructions.
This reads the online user’s query and
translates it into an efficient series of
operations in a form capable of being
sent to the run time data manager for
execution.
54
Database Engine
The core service for storing, processing,
and securing data, this provides controlled
access and rapid transaction processing to
address the requirements of the most
demanding data consuming applications.
It is often used to create relational
databases for online transaction
processing or online analytical processing
data.
55
Report Writer
Also referred to as the report generator,
it is a program that extracts information
from one or more files and presents the
information in a specified format.
Most report writers allow the user to
select records that meet certain
conditions and to display selected fields
in rows and columns, or also format the
data into different charts.
56
Conclusions
Databases have incredible value to
businesses.
Very important technology for supporting
operations.
Vastly superior to file processing systems.
Businesses cannot survive without quality
data about their internal operations and
external environment.
57
Bibliography:
1. Hector Garcia-Molina, Jeffrey D. Ullman, Jennifer
Widom, "Database System Implementation".
2. R. Barker, "CASE Method: Entity Relationship
Modelling (Computer Aided Systems Engineering)".
3. Michael J. Hernandez, "Database Design for Mere
Mortals®: A Hands-On Guide to Relational Database
Design"
4. D.Stamper, W.Price: "Database design and
management: An applied aproach".
5. J.Watson : "Oracle Database 10g OCP all-in-one".
Bibliography: