0% found this document useful (0 votes)
4 views29 pages

01 Introduction RDB

This document serves as an introduction to databases, covering data management, basic concepts, and the relational data model. It discusses the importance of databases in various applications, the differences between file management systems and database management systems, and outlines key concepts such as data, database, data models, and users. The document also emphasizes the characteristics and advantages of the database approach, including data integrity, flexibility, and ease of application development.

Uploaded by

Nguyễn Hưng
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views29 pages

01 Introduction RDB

This document serves as an introduction to databases, covering data management, basic concepts, and the relational data model. It discusses the importance of databases in various applications, the differences between file management systems and database management systems, and outlines key concepts such as data, database, data models, and users. The document also emphasizes the characteristics and advantages of the database approach, including data integrity, flexibility, and ease of application development.

Uploaded by

Nguyễn Hưng
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

11/2/25

Lesson 1:
Introduction to databases
Nguyễn Thị Oanh
oanhnt@[Link]
SoICT, HUST

Plan
• 1. Introduction
• 2. Data management
• 3. Basic concepts on database
• 4. Relational data model

1
11/2/25

1. Introduction
• Major research field with long history (since the
beginning of computer)
• 90% applications use databases
• Hot jobs in startups, big coorporates
• Massive Industry: Oracle, IBM, Microsoft, Google,
AWS

1. Introduction
• How big is our digital universe?

Source: [Link]

2
11/2/25

1. Introduction
• Data science knowledge stack

Source: [Link]
6

2. Data management

3
11/2/25

2. Data management
• What is data?
‒ data is a collection of discrete values that convey
information, describing quantity, quality, fact, statistics,
other basic units of meaning, or simply sequences of
symbols that may be further interpreted.

• What is data management:


‒ Data management is the practice of collecting, keeping,
and using data securely, efficiently, and cost-effectively.

2. Data management
• Case study: List of students of your class
‒ How to collect and store it?
• Excel? Word? ..

‒ How can you share it?


• Email? Google drive? ...

‒ What will happen if you want to modify its content?


‒ What will happen if two people edit simultaneously a file?
‒ If you want to share full information to teachers, and less
infos to students, how will you do?

4
11/2/25

2. Data management
2.1. File management system approach
2.2. Database management system approach

10

10

2.1. File management system


approach

Student Enrollement Lecturer

Student Lecturer

Class Note Course

11

11

5
11/2/25

2.1. File management system


approach
• Limitations
‒ Uncontrolled redundancy
‒ Inconsistent data
‒ Inflexibility
‒ Limited data sharing
‒ Poor enforcement of standards
‒ Low programmer productivity
‒ Excessive program maintenance
‒ Excessive data maintenance

12

12

2.2. Database approach

Lecturer

Database
Lecturer
Enrollement DBMS Student
Class
Course
Note

Metadata
Student
(Catalog)

13

13

6
11/2/25

2.2. Database approach


• Controlled redundancy:
‒ consistency of data & integrity constraints
• Integration of data:
‒ self-contained & represents semantics of application
• Data and operation sharing: multiple interfaces
• Flexibility:
‒ data storage independence, data accessibility, reduced program
maintenance
• Services & Controls
‒ Security & privacy controls
‒ backup & recovery
‒ enforcement of standards
• Ease of application development

14

14

2.2. Database approach


• Characteristics of Database Approach
‒ Self-describing
• DBMS contains catalog (or meta-data) that stores the
description (structures, constraints) of the database
• This allows the DBMS to manage with multiple DBs
‒ Data Abstraction:
• Data model is used to hide storage details
• Users interact with a conceptual view of the DB rather than
dealing with raw storage mechanisms
‒ Sharing of data
• Support multiple views of the same data (a DB) for different
users or applications.
• Allow concurrent access on a DB while maintaining data
integrity and security.

15

15

7
11/2/25

2.2. Database approach


• Characteristics of Database Approach
‒ Persistence
• store data on secondary storage è ensure data durability
‒ Retrieval
• support declarative query language (e.g. SQL), allowing
users to specify what data they need without detailing how
to retrieve it
• procedural database programming language for more
complex operations and procedural logic within the DB.
‒ Performance
• retrieve and store data quickly using indexing, query
optimization techniques
• deal with large volume of data

16

16

2.2. Database approach


• Data Abstraction: 3-tier Schema Model (ANSI-
SPARC Architecture)
…..
END USERS

EXTERNAL LEVEL
EXTERNAL
VIEW 1
….. EXTERNAL
VIEW n

External/Conceptual M apping

CONCEPTUAL LEVEL CONCEPTUAL SCHEMA

Conceptual Internal M apping

INTERNAL LEVEL INTERNAL SCHEMA

STORED DATABASE

17

17

8
11/2/25

3. Basic concepts

20

3. Basic concepts
3.1. Data
3.2. Database
3.3. Data model vs. schema vs. instance
3.4. Database management system (DBMS)
3.5. Database environment
3.6. Database users

21

21

9
11/2/25

3.1. Data
• Definitions

Wikipedia Data is any sequence of one or more symbols


given meaning by specific act(s) of interpretation.

Information in raw or unorganized form (e.g.


Businessdict alphabets, numbers, or symbols) that refer to, or
[Link]
represent conditions, ideas, or objects. Data is
limitless and present everywhere in the universe

‒ E.g. A specific student data: ID, Name, Age, Gender,


Address,…

22

22

3.2 Database
• Example: Course management system
• Important information:
‒ Program, Class, student, course, teacher, ...
‒ Student: personal infos, studying progress
‒ Course: hours, teacher, timetable, ...
‒ ...

ØIt need to store the information


ØDatabase

23

23

10
11/2/25

3.2. Database
• Definitions

Database is a shared collection of related


Wikipedia
data designed to meet the information
needs of an organization
A database is a collection of information that is
Intro to CS
organized so that it can be easily accessed,
managed and updated

‒ E.g.: course management database, Sales management


database, library database, …

24

24

3.2. Database
• Logically coherent & Internally consistent
• Designed for a specific purpose
• Representation of the real world
‒ Entities (e.g., Students, Courses)
‒ Relationships (e.g., Tam is enrolled in C++)
[Example] A course management system

Entities Relationships
• Students • Students take in some
• Courses courses
• Teachers • Course are given by
some teachers

25

25

11
11/2/25

3.3. Model vs. Schema vs. Instance

• Set of concepts used to describe the structure of a


database: data types, relationships, constraints, semantics,
Data Model
• Tool for data abstraction
• Compose of structures and its operators

• Data structure fulfilled all features of the parts of the real


Schema
world which is of interest to the users

• Data itself
Instance

26

26

3.3. Model vs. Schema vs. Instance

type <type_name> = record


<field_name> : <data_type>;
<field_name> : <data_type>;
Data Model end;

type student = record


ID : string;
fullName: string;
Birthday: date;
Schema Address: string ;
Class: string;
end;

( « Stud001 », « Nguyen », 1/4/1983, «1 Dai Co Viet », « 1F


VN K50 »)
Instance

27

27

12
11/2/25

3.4. Database Management System


(DBMS)
• It need a tool that helps to:
‒ Store necessary information correctly

‒ Retrieve information efficiently

ØTools to help build a database and manage it

ØSoftware: DataBase Management System

28

28

3.4. Database Management System


(DBMS)
• Definitions

A software to facilitate the creation and


Wikipedia
maintenance of a database

The DBMS provides users and programmers with a


Techtarget
systematic way to create, retrieve, update and manage data

29

29

13
11/2/25

3.4. Database Management System


(DBMS)
• Core functions:
‒ Defining ~ specifying data types, structures, and
constraints for a DB
‒ Constructing ~ storing the DB structure and populating it
with actual data.
‒ Manipulating ~ querying, updating, reporting data

30

30

Main modules of a DBMS


App

Query processing
and optimization Transaction
managment
DBMS

Storage
managements

Data Data
31

31

14
11/2/25

Example: database exploits


• Student:
‒ List of course of the "Computer Science" departement
‒ Mark of « Database» course?

• Teacher
‒ List of students of the class "124432" in the semester 2022.2
‒ Timetables

• Staff
‒ List of students
‒ Success rate of each course.

ØIt need a software to exploit a database


ØApplication

32

32

Basic concepts
Database System
Application

Database

Database Management
System (DBMS)

33

33

15
11/2/25

3.5. Database Environment


• A database environment (database system) is a
collective system of components that regulates the
management, the use of data, and the data itself
‒ Hardware
‒ Software
‒ Data use and
control the
Application
‒ Users content

‒ Procedures/Manuals
DBMS enable the
database
to be developed
DB DB

34

34

3.6. Database Users


• Database administrators
‒ authorize access to the database
‒ co-ordinate and monitoring its use
‒ acquire software, and hardware resources, controlling its
use and monitoring efficiency of operations.

35

35

16
11/2/25

3.6. Database Users


• Database Designers
‒ define the content, the structure, the constraints, and
functions or transactions against the database.
‒ communicate with the end-users and understand their
needs.
• End-users
‒ use the data for queries, reports and some of them actually
update the database content.
‒ Casual end users
‒ Naive users
‒ Sophisticated end users

36

36

Summary
• Overview
‒ Course overview
‒ Course objective
‒ Motivation for studying databases
• Data management
‒ File management system approach
‒ Database management system approach
• Basic concepts
‒ Data
‒ Database
‒ Data model vs. schema vs. Instance
‒ Database management system (DBMS)
‒ Database environment
‒ Database users

37

37

17
11/2/25

4. Relational data model


4.1. Introduction
4.2. Database Basic concepts
4.3. Constraints
4.4. An example

38

38

4.1. Introduction
• Some of data models:
‒ Hierarchical database model
‒ Network model
‒ Object-oriented database model
‒ Relational model
‒ Entity-relationship model
‒ Document model
‒…

39

39

18
11/2/25

4.1. Introduction
• Relational data model:
‒ Is very simple model, was first introduced by Ted Codd of
IBM Research in 1970
‒ Used by most of commercial database systems
‒ Query with high-level languages
‒ Efficient implementations
‒ Based on mathematical theory, closed to file structure and
data structure, there are three sets of terminology:
Relation Table File

Tuple Row Record

Attribute Column Field

40

40

4.2. Basic concepts


Relations • are saved in the format of tables, which have
rows and columns. The uppercase letters Q, R,
S, ... denote relation names.
Relation • actual contents at given point in time. The
instance/state lowercase letters q, r, s denote relation states
Database • a set of named relations (or tables)

clazz student
clazz_id name lecturer_id monitor_id student_id first_name last_name … clazz_id
20162101 CNTT1.01-K61 02001 20160003 20160001 Ngọc An Bùi
20162102 CNTT1.02-K61 20160002 Anh Hoàng 20162101
20172201 CNTT2.01-K62 02002 20170001 20160003 Thu Hồng Trần 20162101
20172202 CNTT2.02-K62 20160004 Minh Anh Nguyễn 20162101
20170001 Nhật Ánh Nguyễn 20172201

41

41

19
11/2/25

[Link] concepts: a simple database


student subject

Foreign key
enrollment
Foreign key

Primary key

42

42

4.2. Basic concepts


Tuple • A single row of a table, which contains a single recor
d for that relation.
• The lowercase letters t, u, v denote tuples.
Cardinality • Is the number of tuples in a relation.
Degree • Is the number of attributes in a relation.
(arity)

43

43

20
11/2/25

4.2. Basic concepts


• An example
‒ student(student_id, first_name, last_name, dob, gender,
address, note, clazz_id)
Relation / table name
Attributes / Fields/Columns
student

Tuples /
Rows/ Cardinality
Records =6

Degree = 8

44

44

4.2. Basic concepts


• Relational schema: structural description of relations
in database.
‒ A relation schema R of degree n, denoted by R(A1, A2, ...,
An), is made up of a relation name R and a list of attributes
A1, A2, ..., An
student(student_id, first_name, last_name, dob, gender,
address, note, clazz_id)

‒ Each attribute Ai has values belong to domain Di of Ai,


denoted by dom(Ai)
DOM(gender) = {'Female', 'Male'}

45

45

21
11/2/25

4.2. Basic concepts


• Relational schema: structural description of relations
in database.
‒ An n-tuple t in a relation r(R) is denoted by
t = <v1, v2, ..., vn>, where vi is the value corresponding to
attribute Ai
t = <'20220101', 'Hoai An', 'Vu', '2003-12-04', 'M', 'Hai Bà
Trưng, Hà nội', '', '20220101’>

Both t[Ai] and [Link] (and sometimes t[i]) refer to the value vi in
t for attribute Ai
E.g.: t.student_id = '20220101'

46

46

4.3. Constraints
4.3.1. Introduction
4.3.2. Types of constraints
4.3.3. An example

47

47

22
11/2/25

4.3.1. Introduction
• Every relation has some conditions that must hold for
it to be a valid relation
• These conditions are called Relational Integrity
Constraints
• Provide a way of ensuring that changes made to the
database by authorized users do not result in a loss
of data consistency.

48

48

4.3.2. Types of constraints


• Key constraints
• Domain constraints
• Referential integrity constraints

49

49

23
11/2/25

4.3.2. Types of constraints


• Key constraints
‒ A key is an attribute or a set of attributes in the relation,
which can identify a tuple uniquely.
‒ Key constraints force that:
• in a relation with a key, no two tuples can have identical
values for key attributes.
• a key can not have NULL values.
• Key constraints are also referred to as Entity Constraints.

student(student_id, first_name, last_name, dob, gender, address,


note, clazz_id)
Key = {student_id, first_name}
Key = {student_id}

50

50

Some types of key


• Superkey / Key: An attribute, or a set of attributes,
that uniquely identifies a tuple within a relation
‒ Eg: student(student_id, first_name, last_name, dob, gender,
address, note, clazz_id, citizen_id)

Super key = {student_id, first_name}


Super key = {student_id}
Super key = {student_id, first_name, last_name}
Super key = {student_id, first_name, last_name, dob}
Super key = {student_id, first_name, last_name, dob, gender, address,
note, clazz_id, citizen_id}
Super key = {citizen_id}

51

51

24
11/2/25

Some types of key


• Candidate Key / Minimal key : Superkey (K) such
that no proper subset is a superkey within the
relation
‒ In each tuple of the relation, values of K uniquely identify
that tuple (uniqueness)
‒ No proper subset of K has the uniqueness property
(irreducibility)
‒ a minimal set of attributes that can be used to identify a
single tuple (called Minimal key)

Candidate key = {student_id}


Candidate key = {citizen_id}

52

52

Some types of key


• Primary Key: Candidate key selected to identify
tuples uniquely within a relation.
‒ "Good" candidate key
Primary key = {student_id}
‒ Each key attribute of primary key has its name underlined.
student(student_id, first_name, last_name, dob, gender,
address, note, clazz_id, citizen_id)

• Alternate Keys: Candidate keys that are not selected


to be the primary key

53

53

25
11/2/25

4.3.2. Types of constraints


• Domain Constraints:
‒ Attributes have specific values in real-world scenario. Every attribute
is bound to have a specific range of values.
‒ Within each tuple, the value of each attribute A must be an atomic
value from the domain DOM(A).
‒ The data types associated with domains
• standard numeric data types for integers (short integer, integer, and
long integer) and real numbers (float, double precision float).
small integer (2 bytes): -32768 to +32767
• Characters, Booleans, fixed-length strings, and variable-length strings,
date, time, timestamp, and money, or other special data types.
• a subrange of values from a data type: eg. Age>0 ; grade>=0 and
<=10
• an enumerated data type in which all possible values are explicitly
listed: e.g.: gender in {‘F’, ‘M’}

54

54

4.3.2. Types of constraints


• Domain constraints
‒ NULL value
• Represents value for an attribute that is currently unknown /
undefined or not applicable for any tuple;
• deals with incomplete or exceptional data;
• represents the absence of a value and is not the same as
zero or spaces

55

55

26
11/2/25

4.3.2. Types of constraints


• Referential integrity Constraints
‒ Referential integrity constraints work on the concept of
Foreign Keys. A foreign key is a key attribute of a relation
that can be referred in other relation.

‒ Referential integrity constraint states that if a relation refers


to a key attribute of a different or same relation, then that
key element must exist.

56

56

4.3.2. Types of constraints


• Foreign Key:
‒ Attribute, or set of attributes, within one relation that
matches candidate key of some relation
‒ Used to model relationships between relations
‒ Each key attribute of foreign key has its name italic

clazz(clazz_id, name, lecturer_id, monitor_id)


student(student_id, first_name, last_name, dob, gender, address, note, clazz_id)
clazz student
clazz_id name lecturer_id monitor_id student_id first_name last_name … clazz_id
20162101 CNTT1.01-K61 02001 20160003 20160001 Ngọc An Bùi
20162102 CNTT1.02-K61 20160002 Anh Hoàng 20162101
20172201 CNTT2.01-K62 02002 20170001 20160003 Thu Hồng Trần 20162101
20172202 CNTT2.02-K62 20160004 Minh Anh Nguyễn 20162101
20170001 Nhật Ánh Nguyễn 20172201

57

57

27
11/2/25

4.4. An example

clazz(clazz_id, name, lecturer_id, monitor_id)

student(student_id, first_name, last_name, dob, gender, address, note,

clazz_id)

subject(subject_id, name, credit, percentage_final_exam)

enrollment(student_id, subject_id, semester, midterm_score,

final_score)

58

58

4.4. An example
student subject

Foreign key
enrollment
Foreign key

Primary key

59

59

28
11/2/25

Summary
• Relational data model
‒ Relations, relation instance/state, relation schema
‒ Database, tuple
‒ Cardinality, degree
• Constraints
‒ Key constraints
‒ Domain constraints
‒ Referential integrity constraints

60

60

Learning objectives
• Upon completion of this lesson, students will be able
to:
‒ Recall the concepts of database, DBMS, data model, file
system.
‒ Identify the characteristics of database and file system
approach in data management
‒ Recall some basic concepts of relational data model.
‒ Show some constraints of relational data model.

61

61

29

You might also like