Top Banner
Introduction Objectives of the Lecture : •To consider “What is a Database ?” •To consider “What is a Relational Database ?” i.e. what is a “relation”, and therefore what differentiates a relational database from any other kind of database.
16

Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Dec 29, 2015

Download

Documents

Shawn Fletcher
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Introduction

Objectives of the Lecture :•To consider “What is a Database ?”

•To consider “What is a Relational Database ?” i.e. what is a “relation”, and therefore what differentiates a relational database from any other kind of database.

Page 2: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

What is a Database ?

Definition :“A collection of data that is permanently stored on a computer”.

In a database we should be able to : have different types of data in the collection; record relationships between different data items; have varying sizes of data collections to suit our needs.

We need to be able to : insert new data, delete old data, and amend existing data in the collection; retrieve data from the collection; manage the collection so that it can be permanently stored in the face of

various hazards that would otherwise corrupt or lose data in it.

Page 3: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Permanent Data StorageBy “permanent” is meant that once data is put into the computer, it

stays there until someone explicitly removes it, or until the computer is damaged or broken and this causes the data to be lost.The data is not lost when the computer is switched off or the database is not used for a long time.

A computer has 2 classes of data storage : Random Access Memory (= RAM). This is used by the computer’s

Central Processing Unit (= CPU) to temporarily hold data that the CPU is processing.

Backing Store. This is used to store data permanently. Typically magnetic discs are used for this purpose, although other types of storage device, e.g. compact discs and magnetic tapes, are also used.

Thus the database invariably uses the backing store to make the data storage permanent.

Page 4: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Different Types of Data

Numbers

Dates

Audio

Videos

Text

Pictures

Maps

etc.

1, -999, 169.58

14 January 2004

‘Janet & John’

To store useful information, many types may be needed together.Example : recording observations of a species of bird.Number of birds observed, textual description of characteristics, dates of observations, map of migration routes, pictures of birds, audio recording of bird calls, video of flight.

There are many kinds or types of data, such as :

Page 5: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Relationships Between Data

In practice, we are not interested in just isolated items of data. We also want to know the relationships between the data items.

Example : species of bird observationsIt is important to know which bird numbers, descriptions, etc relate to which bird species. It may also be useful to know which bird species have similar migration routes.

All sorts of relationships are possible : some essential to make sense of data, some useful for different purposes.

Page 6: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Quantities of Data

Amounts of data may be large or small:

Example (small) :Names and addresses of members of a golf club (say 500 members).

Example (large) :Electricity company stores all customers’ account details (say name & address, a/c no., meter reading, amount owed, payment method, …. ; 1,000,000 customers).

Example (very large) :Supermarket stores customer purchase details for analysis (say average 10 purchases × 1000 customers × 400 stores × 355 days × 5 years = 7.1 billion purchase details).

Page 7: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Computerised DatabasesWhat is the benefit of a computerised database (= DB)

compared to a manual paper-based collection of data ? Compact. Less bulky than filing cabinets. Speedy. Computer can retrieve and change data faster than a

human being. Less drudgery. Removes tedium. Current. Easier to ensure data is up-to-date.

Often databases are shared by several/many users. Then there are further benefits :

Consistency. All users have the same data. Centralised management. The data collection can be

properly managed on behalf of the whole organisation.

Sharing consistent and well-managed data is much easier to achieve if the database is computerised.

Page 8: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Database Management Systems Need special software to manage the DB if the benefits are to

be obtained. Don’t want to have to write our own computer programs to

do this.

Therefore buy aDatabase Management System (= a DBMS).

A DBMS should provide the means to : change the DB contents to keep them up-to-date; find and retrieve data from the DB; protect the data from accidents and intruders; store it in an efficient way on the computer.

Page 9: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

What is a Relational DB ?Definition :

“A DB in which all the data is stored in relations”.

A relation is a simple logical structure which contains related data (hence the name “relation”). It can be pictured as a table of data

24

6

8

M-S

6

24

8

2SM

D

8M

56

7

8

EName

7

56

8

5SmithMitchell

Robson

8Blake

12

3

4

ENo

3

12

4

1E3E5

E1

4E6

24

6

8

Sal

6

24

8

212,50021,000

32,500

854,000

Example :A relation storing the employee numbers (= ENo), employee names (= EName), marital statuses (= M-S), and salaries (= Sal)of 4 employees.

Row data is related because it all refers to the same employee.The rows are related because they all relate to employees.

Page 10: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

A Relation

The example relation has 4 attributes, depicted as columns

4 tuples,depicted as rows

24

6

8

M-S

6

24

8

2SM

D

8M

56

7

8

EName

7

56

8

5SmithMitchell

Robson

8Blake

12

3

4

ENo

3

12

4

1E3E5

E1

4E6

24

6

8

Sal

6

24

8

212,50021,000

32,500

854,000

As relations are just structures, they can hold any kind of data.So they can hold all the different kinds of data mentioned earlier,and more besides, without limit.

Page 11: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Relational Databases

Relations themselves are based on simple mathematical principles.

Relations can be manipulated by users in ways that are conceptually simple.

A relational DB is perceived and used as a collection of relations.

The relational DBMS manages the physical processing of data so that the user doesn‘t need to know what underlying computer processing goes on and merely perceives things in terms of relations.

Page 12: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Importance of Relational DBMSs

Because relational databases are built on sound theoretical mathematical principles, the theory is very practical.

It makes relational databases easy to learn and use. Nevertheless relational databases can be very powerful and

flexible.

Therefore relational databases : are the most common type of database on the market (over

90% share); are extremely important in practice.

Commercial relational DBMSs usually use a database programming language called SQL. (Thus sometimes they may be called SQL DBMSs).

Page 13: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Terminology

Because relations are usually depicted as tables, the word table is used in SQL instead of relation.

Consequently, as tables have columns and rows, the following tabular names are used in SQL (and often more generally) instead :

table instead of relationcolumn instead of attributerow instead of tuple

Note 1 : some relations are better represented as graphs or networks.

Note 2 : don’t confuse a relation with its representation.

Page 14: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Relational ImplementationsPrinciples

Graphical Text QBE SQL

Oracle

MS Access

MS SQL Server

Calculus Algebra

Domain TupleRAQUEL

IBM’s DB2

Sybase

Ingres

Page 15: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Relational Standards

QBE and relational algebra have not been standardised.

SQL has been standardised. Later standards include additions to SQL compared to earlier standards.

The SQL standards do not adhere completely to relational principles.

Vendors’ SQL implementations often don’t adhere completely to SQL standards, and so are even more ad hoc.

This course uses Oracle SQL, because it is popular in the database market, but it does not adhere completely to the SQL standards.

Page 16: Introduction Objectives of the Lecture : To consider “What is a Database ?” To consider “What is a Relational Database ?” i.e. what is a “relation”, and.

Other Data Models

Hierarchical : data items (= facts) are arranged in a hierarchical structure.

Codasyl/Network : data items are arranged in a network structure.

Object-oriented : data items (= facts) are considered as :• objects containing data,• with their own ways of handling their internal data,• usually arranged in a network structure.

There have been databases that used other data models :-