RDBMS Concepts
RDBMS Concepts
MANAGEMENT
DATA MODELING
DATA MANAGEMENT
2
Relational Data Model
and Management
NoSQL Data Modeling and
Management
Data Distribution
DATA Transaction Processing and
MODELING Consistency Models
Model and
Management
Relational Database
Design and Normalization
Relational Database
Management Systems
(RDMSs)
4
WHAT IS RELATIONAL MODEL?
5
THE 12 RULES OF CODD
01 02 03
In a relational database, all data, Null values are supported to represent Although a relational system can support
including the data dictionary itself, is information not available or not several languages, there should be at
represented in one form, in two- applicable, regardless of the domain of least one language with different
dimensional tables. the respective attributes. characteristics.
04 05 06
Each data element is well determined by
The metadata is represented and In a view, all updatable data that is
the combination of the table name
accessed in the same way as the data modified, should see these changes
where it is stored, primary key value and
itself. translated into the base tables.
respective column (attribute).
6
THE 12 RULES OF CODD
07 08 09
There is the ability to treat a table (basic Changes in the database schema The fact that a database is centralized on
or virtual) as a simple operand (i.e. using (conceptual level), which do not involve one machine, or distributed over several
a set-oriented language), both in query element removals, should not affect the machines, should not have any impact
and update operations. external level - logical independence. on the level of data manipulation.
10 11 12
Changes in the physical organization of The integrity restrictions must be able to
If there is a lower level of record-oriented
the database files or in the methods of be specified in a relational language,
language in the system, it should not
accessing them (internal level) should not independently of the application
allow the integrity and security constraints
affect the conceptual level - physical programs, and stored in the data
to be overcome.
independence. dictionary.
7
OBJECTIVES OF THE RELATIONAL MODEL?
To provide a
Eliminate redundancy,
community view of the
consistency, etc.
data of spartan
problems
simplicity
8
RELATIONAL MODEL CONCEPTS
Attribute Table
Each column in a Table. Attributes are the properties In the Relational model the, relations are saved in the
which define a relation table format. It is stored along with its entities.
Degree Cardinality
The total number of attributes which in the relation is
called the degree of the relation. Total number of rows present in the Table.
9
RELATIONAL MODEL CONCEPTS
10
SQL
STRUCTURED QUERY LANGUAGE
A database language should perform these tasks with minimal effort from the
user, and their structure and syntax should be easy to learn
12
SQL LANGUAGE
U P DAT E DE L E T E
to update data from a to delete the data from a
table. table.
13
SQL LANGUAGE: SELECT
GROUP BY
FROM WHERE forms groups SELECT
Specifies the filters the lines of rows with HAVING specifies ORDER BY
table or subject to condition- which specifies the
the same
tables to be some based group columns output order
value(s) as
used condition filters should
the
appear in the
column(s)
output
14
SQL LANGUAGE: DISTINCT
15
SQL LANGUAGE: WHERE
Match - Compares the value of one Group - checks whether the value of
statement with the value of another a statement falls within a specified
statement. range of values.
16
SQL LANGUAGE: OPERATORS
The BETWEEN operator selects values within a given range. The values can
be numbers, text, or dates.
The BETWEEN operator is inclusive: begin and end values are included.
SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2;
18
SQL LANGUAGE: IN
19
SQL LANGUAGE: LIKE
The LIKE operator is used in a WHERE clause to search for a specified pattern
in a column.
SQL has two special pattern matching symbols:
20
SQL LANGUAGE: NULL
It is not possible to test for NULL values with comparison operators, such
as =, <, or <>.
We will have to use the IS NULL and IS NOT NULL operators instead.
21
SQL LANGUAGE: ORDER BY
22
SQL LANGUAGE: AGREGATION FUNCTION
COUNT - returns the SUM - returns the sum AVG - returns the MIN - returns the
number of values in a of the values of a average of the values smallest value of a
specified column; specified column; of a specified specified column;
column;
23
SQL LANGUAGE: GROUP BY
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
24
SQL LANGUAGE: HAVING
The HAVING clause was added to SQL because the WHERE keyword
could not be used with aggregate functions.
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
25
SQL LANGUAGE: MULTI TABLE QUERIES
A JOIN clause is used to combine rows from two or more tables, based
on a related column between them.
26
SQL LANGUAGE: EXISTS AND NOT EXISTS
27
SQL LANGUAGE: COMBINE TABLES
28
SQL LANGUAGE: UNION, INTERSECT, EXCEPT
29
SQL LANGUAGE: DATABASE CHANGES
30
SQL LANGUAGE: INSERT
It is possible to write the INSERT INTO statement in two ways. The first way specifies
both the column names and the values to be inserted. The second way only
specifies the table and the values.
Make sure the order of the values is in the same order as the columns in the table
31
SQL LANGUAGE: UPDATE
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
32
SQL LANGUAGE: DELETE
33
RELATIONAL DATABASE DESIGN AND
NORMALIZATION
Standardization is a systematic process, defined by a set of well-defined
rules, aimed at eliminating sources of redundancy in data:
• Maintenance problems;
• Storage space costs;
• Performance problems.
For the next slides, the case to be type as an example should be that of a
medical clinic. The following restrictions should be considered:
• A doctor only consults a specialty.
• The price of the consultation depends on the specialty.
• During the consultation treatments can be made to the patient that will
be paid together with the consultation.
• The clinic has 30 doctors consulting 10 specialties, for a universe of 10000
patients, having about 50 consultations per day.
35
NORMALIZATION: 1ST NF
A table is in 1FN, if and only if, all the values in the table columns are atomic
36
DEPENDENCIES
37
NORMALIZATION: 2ND NF
Appointment(cod_med,date,hour,n_ben,patient,age,address,co
Analysis of d_post,city, price)
functional
dependencies.
1.cod_med,date,hour, 2.n_ben>patient,age,address,
n_ben->price cod_post,city
The second dependency is at odds with the definition of the 2ndFN.
Generation of The solution is to decompose the relationship according to the previous
new tables with functional dependencies:
complete Appointment(cod_med,date,hour,n_bem,price)
functional Patient(n_ben ,patient,age,address,cod_post,city)
dependencies. 38
NORMALIZATION: 3RD NF
39
NORMALIZATION: 3RD NF
Taking the example again, we see that in the Medical relationship there are two
functional dependencies
Doctor(cod_med,name,address,contact,age,cod_esp,especiality,price)
n_ben ->
cod_post ->
pacient,age,address,cod_pos city
The solution is to decompose the relationship again according to the previous
functional dependencies:
• Patiente(n_ben ,pacient,age,address,cod_post)
• Cod_Postal(cod_post,city)
41
NORMALIZATION: BOYCE CODD NF
A relational database
A relational database is a type
A database is a set of management system (RDBMS) is
of database. It uses a structure
data stored in a a program that allows you to
that allows us to identify and
computer. This data is create, update, and administer
access data in relation to
usually structured in a a relational database. Most
another piece of data in the
way that makes the relational database
database. Often, data in a
data easily accessible. management systems use the
relational database is organized
SQL language to access the
into tables.
database.
43
RDBMS VS. DBMS
An RDBMS is a type of database management system (DBMS) that stores data in a table which connects related
data elements.
• A RDBMS includes functions that maintain • It does not apply any security protocol with
data security, accuracy, integrity and respect to data manipulation.
consistency; • The DBMS stores the data as an archive;
• The data is stored in table form; • Supports only one user;
• Supports multiple users; • Does not support client-server architecture;
• supports client-server architecture • Requires few software and hardware
• It has high software and hardware requirements
requirements • It does not take into account the concept
• Keys and indexes do not allow data of standardization, leading to redundancy
redundancy. in data.
44
ADVANTAGES OF RELATIONAL DATABASE
MANAGEMENT SYSTEMS
Data Structure
The table format is basic and easy to use and understand for database users. RDBMS allow data to be accessed via a
native structure and organization of the data. Database queries can search each column for corresponding entries.
Maintenance
RDBMS have maintenance programs that provide administrators with tools to simply maintain, test, repair and
back up the databases hosted on the system. Many of the features can be automized through the built-in
automation in the RDBMS.
Network Access
RDBMS provide access to the database through a server daemon, a dedicated software program that listens for
requests on a network and allows database clients to connect to and use the database.
45
ADVANTAGES OF RELATIONAL DATABASE
MANAGEMENT SYSTEMS
Multi-User Access
RDBMS allow several users to access a database synchronously. Built-in lock and transaction management
features help users access data as it is being changed, prevent conflicts between two users who are updating
data, and prevent users from accessing partially updated records.
Privileges
Authorization and privilege control features in an RDBMS allow the database administrator to restrict access to
authorized users, and grant privileges to individual users based on the types of database tasks they need to
perform. Authorization can be defined based on the remote client IP address in combination with user
authorization, restricting access to specific external computer systems.
Language
RDBMSs support a generic language called "Structured Query Language" (SQL). The SQL syntax is simple, and the
language uses standard English language keywords and phrasing, making it fairly intuitive and easy to learn. Many
RDBMSs add non-SQL, database-specific keywords, functions and features to the SQL language.
46
POPULAR RELATIONAL DATABASE MANAGEMENT
SYSTEMS
47