0% found this document useful (0 votes)
3 views

Database System Lecturing v 3

The document provides an introduction to database systems and the relational database model, covering key concepts such as data processing, types of data, and the importance of database management. It discusses the relational data model, including terminology, relationships, and normalization, as well as the use of SQL for database queries. Additionally, it outlines the development of databases through system analysis, design, and entity-relationship modeling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Database System Lecturing v 3

The document provides an introduction to database systems and the relational database model, covering key concepts such as data processing, types of data, and the importance of database management. It discusses the relational data model, including terminology, relationships, and normalization, as well as the use of SQL for database queries. Additionally, it outlines the development of databases through system analysis, design, and entity-relationship modeling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Introduction to Database System

and
Relational Database Model
Yan Watequlis Syaifudin
Master course’s presentation, Okayama University, Japan
Concept of Database

Relational Data Model

Query Language

OUTLINE
Database Development

Q&A

Post Test
1. Concept of Database
DATA PROCESSING IN THE WORLD
Definitions
 Data: stored representations of meaningful objects and
events or
 Referred to facts concerning objects and events that

could be recorded and stored on computer media


 Structured: numbers, text, dates
 Unstructured: images, video, documents
 Information: data processed to increase knowledge in
the person using the data
 Metadata: data that describes the properties and

context of user data

5
Types of Data
INFOGINEERING MODEL

Example (Case : Parking Area in Shopping Center)


Data Information Knowledge Decision
Individual Car Parking Parking Report in There are many cases Need to expand
with Time and Cost. Current Year parking capacity was car parking space.
Parking Capacity overload in weekend of
this year.

Other examples: Weather forecast, Personal knowledge??


Future
Journey from Data to Wisdom

Understanding
Principles
???

Data Mining, Web Mining,


Understanding Knowledge Management System,
Patterns Expert System, Data Analysis.
Nowadays

Management Information System,


Understanding Transaction Processing System,
Data Warehousing, Semantic Web,
Relationships Web crawling, Web scrapping,
Information retrieval.
Importance of Database System
Data are corporate asset that similar with personnel,
financial, building, and equipment.

Important assets of the organization need to be managed


properly.

To be useful, data must be processed into information. It


must be accurate, timely, and relevant.

We need adequate facilities for storing data and processing


information. (storing, manipulating, and extracting).

Hence, effective data and database administration provide


support for managerial decision-making.
Digital data processing
Database Management System
Database :
• an organized
collection of data,
generally stored and
accessed electronically
from a computer
system.
Database management
system:
• refers to the
technology solution
used to optimize and
manage the storage
and retrieval of data
from databases.
• Databases become
more complex, they
are often developed
using formal design
and modeling
techniques.
Relational Distributed Cloud NoSQL Hybrid
DATABASE MODEL
Model Characteristic Period Sample
Relational a mathematical model defined in 1980-now Oracle, DB2, SAP
terms of predicate logic and set Sybase ASE,
theory. introduced by E.F. Codd in MySQL, Microsoft
1970. SQL Server.
Hierarchical data is organized into a tree-like 1970- IMS by IBM.
structure. widely used in the early 199x
mainframe database management XML, JSON.
systems.
Flat Table a table model consists of a two- 1960- FileMaker, dBase,
dimensional array of data elements 198x spreadsheet.
and stored in a file called a flat file.
Object- creating a new database model 1990-now ObjectDB, Realm.
oriented known as object databases.
Graph uses graph structures for semantic 1990-now OrientDB, SAP
queries with nodes, edges, and HANA, ArangoDB,
properties to represent and store Microsoft SQL
data Server 2017
Relational vs Non-relational
(The Types of Modern Databases)
SQL/RDBMS/Relational NoSQL/Non-Relational
Databases Databases
• A collection of tables, each • NoSQL databases emerged as
with a schema that represents a popular as web applications
the fixed attributes and data became increasingly complex.
types that the items in the • RDBMS schemas rigidly define
table will have. how all data inserted into the
• RDBMSs all provide database must be typed and
functionality for reading, composed, whereas NoSQL
creating, updating, and databases can be schema-
deleting data, typically by agnostic, allowing
means of Structured Query unstructured and semi-
Language (SQL) statements. structured data to be stored
and manipulated.
Relational
vs
Non-relational
Databases
2. Relational Data Model
RELATIONAL DATA MODEL
• A Relational DBMS expresses data in terms of a “relation” or a table consist of
named columns with data organized into rows.
• Relationships are NOT physically implemented. It is realized by foreign keys.
• Terminology: relations (tables), columns, tuples (rows), domain, degree,
cardinality, primary keys, concatenated keys, alternate keys, foreign
keys, Referential Integrity or R.I.
• Relational algebra, three main operators: select, project, join
• Normalization theory: 1NF, 2NF, 3NF
• Database schema design: Entity-Relationship Diagram, Conceptual Data
Model.
Formal relational term Informal equivalents
relation table
tuple row or record
cardinality number of rows
attribute column or field
degree number of columns
(unique) identifier Primary key
domain pool of legal values

Terminology
in Relational
Database
Relation (Table)
 Two-dimensional structure with rows and columns.
 Table also called a relation because the relational model’s
creator, Codd, used the term relation as a synonym for table.
 A relation represent a single entity.
 Each table must have an attribute to uniquely identify each row.
 Column values all have same data type.
 Order of the rows and columns is immaterial to the DBMS.
Rules of Relation (Table)
1. There are no duplicate tuples (rows).
• The body of the relation is a mathematical set (i.e., a set of tuples),
and sets in mathematics do not include duplicate elements.
• If a "relation" contains duplicate tuples, then it is not a relation.
2. Tuples (rows) are unordered (top to bottom).
• Sets in mathematics are not ordered. So, even if a relation A's tuples
are reversely ordered, it is still the same relation.
• Thus, there is no such thing as "the 5th tuple" or the last tuple. In
other words, there is no concept of positional addressing.
3. Attributes (columns) are unordered (left to right).
• The heading of a relation is also defined as a set.
• There is no such thing as "5th attribute (column)" or the last
attribute.
4. All attribute values are atomic.
• At every row-and-column position within the table, there always
exists precisely one value, never a list of values. Or equivalently,
relations do not contain repeating groups.
• A relation satisfying this condition is said to be in First Normal Form.
Keys
 Consists of one or more attributes that determine other
attributes.
 Primary key (PK) is an attribute, or collection of attributes,
whose values uniquely identify each tuple in a relation.
 To being unique, a PK must be minimal (contain no
unnecessary attributes) and must not change in value.
 Key’s role is based on determination
• If you know the value of attribute A, you can look up (determine)
the value of attribute B

21
Foreign Key
• A relation schema may have an attribute that corresponds to
the primary key of another relation. The attribute is called a
foreign key.
• It is an attribute (or combination of attributes) in one table
whose values must either match the primary key in another
table or be null.
• In relational database, foreign key represent the relationship
between 2 or more relations/tables.
Relationships within Relations/Tables
(Cardinality)
a) 1:M (one to many) relationship
• Relational modeling ideal
• Should be the norm in any relational database design
b) 1:1 (one to one) relationship
• Should be rare in any relational database design
c) M:N (many to many) relationships
• Cannot be implemented as such in the relational model
• M:N relationships can be changed into two 1:M relationships

Lets identify

23
The 1:M Relationship
• Relational database norm
• Found in any database environment

Q : Give example?
24
The 1:1 Relationship
• One entity can be related to
only one other entity, and vice
versa
• Sometimes means that entity
components were not defined
properly
• Could indicate that two entities
actually belong in the same
table
• As rare as 1:1 relationships
should be, certain conditions Q : Give example?
absolutely require their use
25
The M:N Relationship
• Yields required M:N to 1:M conversion
• Linking table must contain the primary keys of original tables
• L.T. contains multiple occurrences of the foreign key values
• Additional attributes may be assigned as needed

Q : Give example? 26
RD Schema: a case study
3. Query Language
Data Query Language
• Query languages or data query languages (DQLs)
are computer languages used to communicate with DBMS.
• The most popular relational database query language is SQL
(Structured Query Language), created by IBM in 1974.
• The standard of SQL is ANSI SQL.
Implementation of SQL in RDBMS
Many types of SQL exist, including MySQL, PostgreSQL, PL/SQL
(Procedural Language/SQL, used by Oracle), T-SQL and ANSI SQL
(used by Microsoft SQL), and many others.
Type of SQL Statements
Data Definition Language (DDL)
 Use to define the database structure or table.

Statement Description
CREATE Create new database/table.
ALTER Modifies the structure of database/table.
DROP Deletes a database/table.
TRUNCATE Remove all table records including allocated
table spaces.
RENAME Rename the database/table.
Data Manipulation Language (DML)
 Use for managing data within table object.

Statement Description
SELECT Retrieve data from the table.
INSERT Insert data into a table.
UPDATE Updates existing data with new data within a table.
DELETE Deletes the records rows from the table.
MERGE MERGE (also called UPSERT) statements to INSERT new
records or UPDATE existing records depending on
condition matches or not.
LOCK TABLE LOCK TABLE statement to lock one or more tables in a
specified mode. Table access denied to a other users
for the duration of your table operation.
Data Control Language (DCL)
 Use to give privileges to access limited data.

Statement Description
GRANT Gives privileges to user for accessing database
data.
REVOKE Take back for given privileges.
ANALYZE ANALYZE statement to collect statistics
information about index, cluster, table.
AUDIT To track the occurrence of a specific SQL
statement or all SQL statements during the
user sessions.
COMMENT Write comment to the data table.
SQL: A Case Study
Student Room
id name id name capacity
1000 James Smith C01 Class Room 01 24
1001 Ada Lovelace M01 Meeting Room 20
1002 小嶋陽菜 C02 Class Room 02 24
1003 James Smith G01 General Room 01 100

Enrolled
Course
student_id course_id grade
id name room_id
1000 IT101 A
IT101 Mathematics C01
1000 IT102 B+
IT102 Programming 1 C02
1003 IT301 A+
IT301 Network System C01
1003 IT302
IT302 English Lecture M01
1002 IT402
IT402 Advanced Network
1001 IT402 A+
Creating a table
CREATE TABLE table_name (
Basic syntax column1_name column1_type,
column2_name column2_type,

);

CREATE TABLE Student ( CREATE TABLE Room (


id char(4) PRIMARY KEY, id char(3) PRIMARY KEY,
name varchar(30) name varchar(20),
); capacity INTEGER
);

Student Room
id name id name capacity
Adding a single row / rows (Insert)
Basic syntax
INSERT INTO table_name VALUES (val1,val2,val3,…);

INSERT INTO Student VALUES INSERT INTO Room VALUES


(’1000’,’James Smith’); (’C01’,’Class Room 01’,24);
INSERT INTO Student VALUES INSERT INTO Room VALUES
(’1001’,’Ada Lovelace’); (’M01’,’Meeting Room’,20);
INSERT INTO Student VALUES INSERT INTO Room VALUES
(’1002’,’小嶋陽菜’); (’C02’,’Class Room 02’,24);
INSERT INTO Student VALUES INSERT INTO Room VALUES
(’1003’,’James Smith’); (’G01’,General Room 01’,100);

Student Room
id name id name capacity
1000 James Smith C01 Class Room 01 24
1001 Ada Lovelace M01 Meeting Room 20
1002 小嶋陽菜 C02 Class Room 02 24
1003 James Smith G01 General Room 01 100
Show table content (Select)
Basic syntax SELECT column_list FROM table_name
[WHERE condition] [ORDER BY column_list];

SELECT * FROM Enrolled; SELECT student_id,course_id


FROM Enrolled WHERE grade=’A+’;

student_id course_id grade student_id course_id


1000 IT101 A 1003 IT301
1000 IT102 B+ 1001 IT402
1003 IT301 A+
1003 IT302 SELECT student_id,course_id
FROM Enrolled WHERE grade=’A+’
1002 IT402 ORDER BY student_id;
1001 IT402 A+
student_id course_id
1001 IT402
1003 IT301
4. Database Development
Development of Database
System Analysis & Design
DFD Data Stores, Data Flows, and Data Dictionary

Entity-Relationship Relational Data Normalization Form


(ER) Modelling Model (Table Set) (NF)

DBMS
Physical View of Data Logical View of Data
(Tables) (Forms)

Database connectivity Database connectivity Database connectivity


via websites via database tools via programming
(PHP, ASP .NET, JSP) (Firebird, SQL Server languages
Manager, Adminer) (Java, VB .NET, C#)
Entity-Relationship Diagram
• ER Modelling, an abstract data model, describes interrelated
things of interest in a specific domain of knowledge.
• A basic ER model is composed of entity types and specifies
relationships that can exist between entities.
Data Normalization
• the process of structuring a relational
database to reduce data redundancy and
improve data integrity.
• there are 6 steps of normalization process.
Discussion
• What are the advantages of DBMS?
• What are the various types of relationships in
Database? Define them.
• What is SQL?
• Why was the No-SQL database growing popular?
• How to develop the database system?
Post Test
• What is the difference between relational and non-
relational database?
• Give an example of SQL statement to
create/insert/select table.

You might also like