You are on page 1of 50

Databases Introduction

& Data Modelling

1
Executive Summary

• Why databases?
• What is a database?
• Web vs. database
• Approaches to data management
• Data modelling
• E-R model
• Review questions

2
Databases are in your life
• Shift from computation to information
• True in corporate computing for years
• Web, p2p networks made this clear for personal computing
• Increasingly true of scientific computing
• Need for database technology has exploded in the last years

Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

3
Databases are in your life

• Corporate: retail swipe/clickstreams, “customer


relationship management”, “supply chain
management”, “data warehouses”, etc.
• Web: not just “documents”. Search engines, e-
commerce, blogs, wikis, other “web services”.
• Scientific: digital libraries, genomics, satellite
imagery, physical sensors, simulation data
• Personal: Music, photo, & video libraries. Email
archives. File contents (“desktop search”).
Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

4
Database Systems Then

Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

5
Database Systems Today

6
6
Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/
Database Systems Today
Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

7
7
Database Systems Today
Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

8
Database Systems Today

Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/
9
9
So… What is a Database?

• Intuitively: „place“ where we store our data in


electronic form

• According to ISO standard: a collection of


interrelated data stored together in one or more
computerized files. (ISO/IEC 24765, Systems and Software
Engineering Vocabulary)

• In general: A logically organized collection of related


data designed and built for a specific purpose.
Source: Williams: Using Information Technology, 10e, 2013

10
Database Management System
• A Database Management System (DBMS) is:
– A software designed to store, manage, and facilitate access
to databases.
– It provides interface between database and application
program
• Purpose of DBMS:
– To define and construct the database and to manipulate
with it

Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

11
Database system (DBS)
Information system (IS)

Database system (DBS)

DBMS

Database (DB)

12
Database Management System (DBMS)

• Typically this term used narrowly


– Relational databases with transactions
• E.g. Oracle, DB2, SQL Server
• Basic parts of DBMS:
– Program to define data (to create and change data
structures)
– Program to manipulate data (to insert and update
data, to search, to select and to present data and
to create forms and reports)
– Program for access control of users to data

13
Database system (DBS)
• It works according to the equation:
DBS = DB + DBMS
• Data are organized in database (DB) and
managed by database management system
(DBMS)

14
Beware terminology

Database ¹ Database system !

15
MS Access 2013

Source: own

16
MS SQL Manager

Source: J. Tyrychtr: Internet technologies, 2012

17
MySQL Manager

Source: J. Tyrychtr: Internet technologies, 2012

18
Database design – Critical topic

• What do I want?
– (Outputs)
• What have I got?
– (Inputs)
• What do I need to do to get
there?
– (Process)

Source: AIN100A Microsoft Access Level 1, 2011

19
Define your needs first

• Draw a picture
• Write a description PRODUCTS

SUPPLIERS
ORDERS

C.C.
EMPLOYEES Toys

Source: AIN100A Microsoft Access Level 1, 2011

20
Introduction to MS Access

21
MS Access Modes

• Menu-driven interface – Interacts with a


database and its objects using menu
commands
• Program mode – Lets you store instructions in
a VBA program file
• This course concentrates on the menu
interface (we will not do programming in VBA)
Source: AIN100A Microsoft Access Level 1, 2011

22
Database Terminology

• Database – in Access a repository in which tables,


reports, queries, and other objects are stored
• Table – stores facts about one subject (entity)
• Record – contains related information about an
entity “instance”
• Field – contains a fact about an entity
• Relational Database – allows you to link records
from two or more tables based on the contents of a
common field. Access is a relational database.
Source: AIN100A Microsoft Access Level 1, 2011

23
Database Terminology (cont.)

• Key – used to order, identify, and retrieve records in


the database
• Primary key – unique identifier for a particular
record. Only one per table.
• Index – like a book index. Speeds searches and joins.
Can have many per table
• Table structure – the arrangement of information
within a record, the type of characters, field length,
limitations, etc.
Source: AIN100A Microsoft Access Level 1, 2011

24
To be continued at lecture no. 2 …

25
Managing digital data

• Two different approaches to maintaining data:


– Traditional file approach
– Database approach

26
• A database is a logically organized collection of
related data designed and built for a specific
purpose
• Data is stored hierarchically for easier storage and
retrieval
• File (table): collection of related records
– Records (row): collections of related fields
• Field (column): unit of data containing 1 or more
characters
– Character [Byte]: a letter number or special character
made of bits
» Bit: 0 or 1
Source: Williams: Using Information Technology, 10e, 2013

27
Data Storage Hierarchy

Source: Williams: Using Information Technology, 10e, 2013

28
Files vs. Database
• Data stored in files (traditional)
Eg. MyHomework.doc

+ Good portability
+ Supported by the operating system (OS) ->
no special software needed
- Program/data dependency
- Trouble with sharing data

29
Files vs. Database

• Data in database

+ No dependency between data and program


+ Low data redundancy
+ High data integrity
+ Data sharing among applications
- Trouble with data portability
- Higher cost of database systems

30
Files vs. Databases
• Thought Experiment 1:
– You and your project partner are editing the same file.
– You both save it at the same time.
– Whose changes survive?

A) Yours B) Partner’s C) Both D) Neither E) ???


• Thought Experiment 2:
–You’re updating a file.
–The power goes out.
–Which changes survive? Source: http://inst.eecs.berkeley.edu/~cs186/fa05/lecs/

A) All B) None C) All Since Last Save D) ???


31
Review Questions - 1
1. Give three areas where databases have become important today?
2. Give one real example of a database.
3. What is a database in general? What is a database in particular?
4. Give one example of an entity and one example of a relationship
between entities.
5. What are differences between data on the Web and data in the
database? Explain.
6. What does it mean that data are dependent on program under
traditional file approach?
7. In which points, does database approach win over traditional file
approach?

32
How to Create a Database?
• Firstly, to set a data model for database
• Data model is:
– a plan for building a database
– a representation of data structure required by a
database
• Data model includes:
– data objects (=entities),
– associations between data objects
(=relationships),
– rules which govern operations on the objects
• Data model is independent of hardware or software

33
Why Data Model?

• In construction building: to build a house without is


impossible
• In data modelling: to build a database without a plan
is impossible
• Goal of modelling – ensure that all relevant physical
objects are in database
• More time intensive but worthy

34
Data model

• Helps the end user to understand the data


model
• Corrections and changes to model are much
easier than correction and changes to real
database

35
Methods for Data Model

1. Hiercharchical model
2. Network model
3. Entity-relationship model (E-R model)
4. Object-oriented model

36
E-R Model

• Views the real world as entities and


relationships
• Visual representation of data objects by a
diagram

37
Database examples

Searching on the web


Football game
- words, documents
- teams, games
- „Microsoft“ leads to
- AC Milan is playing
Microsoft official website
Championships League
from Google search results

iTunes library Study at CULS


- songs, artists, albums - students, teachers, courses
- Justin Timberlake released - John Smith attends
new album on iTunes Information technologies
course

38
E-R Model Background

• E-R diagrams were originally


proposed in 1976 by Dr. Pin-Shan
(Peter) Chen
• E-R model today serves for Dr. Peter Chen (陳品山)

information system design, all


major database systems can
handle it (IBM, Oracle, Microsoft)

39
E-R Model
Entity STUDENT
• Is a data object
(concrete or abstract) to
collect information about it
• It has its name, eg. EMPLOYEE, BOOK, STUDENT,
etc.
Even there are many employees, many books and many students, the
singular is used for the name
• Will be represented as a table later in the relational
database

40
E-R Model
STUDENT
Attribute Name
• Describes the entity Surname
Birth date

• An instance attribute
is a single value of an attribute for an instance of
entity (eg. “John” for attribute Name)
• Collection of all possible values
of an attribute is a domain (eg. Character string, date,
number, etc.)

41
E-R Model
Relationship STUDENT STUDY GROUP

• Association Name Number


Surname
between two Birth date belongs

or more entities
• Eg. „Student belongs to study groups“
• Relationships are classified in terms of degree,
connectivity, cardinality and existence

42
E-R Model
Relationship - cardinality
• Is a number of occurences for
a particular entity STUDENT STUDY GROUP

Most frequent use: Name N 1 Number


Surname
• one-to-one (1:1) Birth date belongs

• one-to-many (1:N)
• many-to-many (N:N)

43
Examples and explanations of
relationships
• Student – Student‘s book is 1:1 (Explanation: each
student has its own one unique index and each index
belong only to one student)
• Student – Study group is N:1 (Explanation: each
student belongs only to one study group, but each
study group has one or more students)
• Student – Subject is M:N (Explanation: each student
can have one or more subjects, conversely one
subject can be attended by one or more students)

44
E-R Model

Key attribute STUDENT


• A field that value uniquely identifies ID
the full record. Name
• The name of the key attribute is usually Surname
Birth date
underlined in the E-R diagram
• For example: If we know the student’s ID we can
get full record of that student by typing the ID
value (e.g. ‘1’).

45
Steps In Building the Data Model
(simplified)
1. Identify data objects and relationships
2. Draft the initial E-R diagram with entities and
relationships
3. Refine the E-R diagram
4. Add key attributes to the diagram
5. Add non-key attributes

46
Data Model – Example 1

Assignment no.1: “Design and draw a model for


the evidence of books and their borrowers in
the library”

47
Data Model – Example 2

Assignment no.2: “Design and draw a model for


the evidence of university students and their
examinations”

48
Review Questions - 2
1. What is the first step before we create a database?
2. Why is data model so important for building database? Give two
reasons.
3. Give the list of steps that are necessary for data model design.
4. What is the E-R model? Explain.
5. What is the entity in E-R model? Give two examples.
6. Fill in correct words (entity, attribute, instance of attribute, domain) in
the assignment:
“In the E-R model of books in library, the “Book” is an …… in the
model. The book must have information about the author, the title of
book, the publisher name and the year of publishing that are
represented as …….. in the model . If there is a book “Lord of the
Rings” , it is an ………. of the attribute “book title”. The “book title”
could be represented only as a text value, which is the ……”

49
Review Questions - 2

5. What does it mean if there is 1:1 relationship? Give one


example.
6. Which kind of relationship is between entities
“Student” and “Subject”? Explain.
7. Which kind of relationship is between entities “Customer”
and “Order”? Explain.
8. Which kind of relationship is between entities
“Bank loan” and “Client”? Explain.

50

You might also like