Overview of Database Management Systems
Overview of Database Management Systems
The information constitutes the content of the database. In order for it to be stored and managed, it ...
information requires a structure. This structure is created and maintained by the system software
of database management (DBMS).
The database is an integral part of the so-called SiInformation systems,where the data are
collected, processed, organized and stored. The part of collection, treatment and
data processing is donefor programsspecifics such as: ERP, CRM, web service, websites,
etc. However, the storage and organization of this data are done in a database,
podendo ser ele Oracle, SQL Servidor, MySQL ou outro.
Currently, databases are called relational because their structures are formed
through tables and relationships between the tables. Both a robust database like Oracle or a
desktop like Access adopts this same standard, making it easy and possible for integration
data between banks
1
Computer Science 2018
General purpose: To store information and allow users to search and update it.
efficient and quick information when needed
Users can:
Insert
Search
Update e
Remove data.
Advantages
Data organization: the structure of the data is too complicated to be stored in tables.
Data volume: the volume of data is too large to be stored in a table
Speed/Efficiency: The data is obtained and updated quickly in the database.
• Concurrency: different applications/users can share the same data
Controlled redundancy: shared data does not need to be replicated
Applicability: Reduction in the application development time
2
Computer Science 2018
Database management systems are programs that allow the creation and manipulation of databases.
of data, in which data are structured with independence relative to the programs
of application that manipulate them.
Concurrency Control - Limits simultaneous changes and readings of the same data by
different users;
Backup – a reconstruction mechanism that allows the database to return to
consistent state;
Security - can establish restrictions on access to each item of information;
Integrity - maintaining the consistency of the database through the validation of constraints;
Atomicity – either the transaction occurs or it does not.
· Physical level:
3
Informatics2018
· Conceptual Level
· Viewing level
The software of this system is complex and the concepts used are, often,
new for users. Thus, it requires specialized personnel in IT and,
sometimes, it is necessary to reduce the number of users of the DBMS;
The software causes additional overhead (resource degradation) because it is slower in execution.
It requires more disk space.
Whatisadatabase?
4
Computer Science 2018
Database Models
The models used for the creation of databases can be classified into
two main groupings:
Object-based models
Record-based models
The register-based models have the common feature of trying to represent reality.
through registers. These registers correspond to the registers used in programming containing
structured information with field format.
۵ Hierarchical model
۵ Network model
۵ Relational model
Advantages of a database
5
Informatics2018
Microsoft Access
FileMaker
Microsoft SQL
Oracle
Informix
DB2
Etc.
These are some of the products that allow you to create, use, and maintain databases.
We start by defining the tables, that is... the drawers of the data...
6
Computer Science 2018
To a certain extent, we can translate almost all types of entities, situations into tables.
events, etc... For this, it is enough for us to define some of the characteristics of these
entities such as CAMPOS.
TheFIELDSbecomethecolumnsofthetableandtherowsbecomeRECORDS.
Notion of table
The information stored in a table must be consistent with the criteria used for the
your creation - containing only the data that pertains to the subject, to which it is given
name of entity.
Notion of field
Notion of registration
Notion of relationship
Association established between common fields (columns) of two tables, allowing for
the awareness of information be guaranteed
7
Computer Science 2018
the relationship between the common fields of the tables allows to ensure that the awareness
that the information is not called into question and also to associate the data of two or
more tables for the visualization, editing or printing of the information.
Notion of association
Binary-existenceofanytypeofrelationshipbetweentwoentities
Concept of key
The key of a table is made up of one or more fields that can be used as
identifiers of each record.
Thekeyfieldsmustallowtherecordtobeidentifieduniquely.
The field or set of fields selected for the key of a table cannot contain
repeated information.
TYPE OF FIELD...
2. If we want to perform calculations, we have to define it as numeric. There are 2 records with
the same content for the primary key.
[Link]:Therecannotbeanyprimarykeyattributethatcontainsanullfield.
8
Computing2018
Relational model
Relational Model
Data is perceived as tables (relations);
Attributes (table fields);
Keys:
Primary: an attribute that identifies the entity.
It must be unique for each record;
Foreign keys: attribute to reference entities in other tables.
Advantages
Little physical space occupied
Elimination of usage redundancy
Ease and speed of handling stored information
Less deterioration of the medium used (microfiche, magnetic, optical)
More truth in the combination of data, more information
• Data organization
• Concepts of the model
• Attribute, relation, key,
• Integrity
• Basic restrictions for data and relationships
• Manipulation
• Formal languages and SQL
9
Informatics2018
CONCEPT OF KEYS
A key is an attribute or a set of attributes that allows for the unique identification of
records (entities or occurrences) of a table. All possible keys of a table or
entity - simple or composite - are designated as candidate keys. Among the candidate keys
existing in a table, one of them will be the most indicated or chosen to perform the role of
key - this will be designated as the primary key. A primary key is therefore a
attribute or set of attributes that serves to uniquely identify entities
or records of a table.
10
Informatics2018
table, then, from the point of view of this last table, said that it is about an external key
(secondary). Therefore, a foreign key (secondary) is an attribute that is a primary key of
a table and it will appear as an attribute of another table. It is fundamentally through the
inclusion of attributes that are primary keys (in their source tables) in other tables (where
are secondary keys) that establish the relationships between the different entities of
a relational database.
With the adventfrom the Entity-Relationship Model a confusion was caused among the
termsrelationship and relationship
One to one(1 for 1) - indicates that the tables have a unique relationship with each other. You choose
which table will receive the foreign key;
One for many1 for N)the primary key of the table that has side 1 goes to the table
on side N. On side N it is called a foreign key;
Many to manyN for N)when tables have a n.n relationship with each other, it is necessary to create
a new table with the primary keys of the involved tables, resulting in a key
11
Informatics2018
composed, that is, formed by several key fields from other tables. The relation then
it reduces to a 1.n relationship, where the n side will have the new table created.
Normalization is a process through which rules are applied to all tables in the database.
data with the aim of avoiding project failures, such as data redundancy and mixing of
different subjects in the same table.
When designing a database, if we have a model of entities and relationships and from there
let's build the relational model following thetransformation rulescorrectly, the
the resulting relational model will probably be normalized. But not always the models
what we encounter is implemented this way and, when that happens, the support for the bank
data is difficult.
1NF - 1st Normal Form: all attributes of a table must be atomic, that is, the
the table should not contain repeated groups or attributes with more than one value. To leave
In this normal form, it is necessary to identify the primary key of the table, to identify the(s)
column(s) that have repeated data and remove it/them, create a new table with the key
primary to store the repeated data and, finally, create a relationship between the table
main and the secondary table. For example, consider the following People table.
12
Computer Science 2018
It contains the primary key ID and the TELEFONES attribute is a multivalued attribute and,
Therefore, the table is not in 1NF. To put it in 1NF, we will create a new table.
table TELEPHONES that will contain PERSON_ID as a foreign key from PEOPLE and
TELEPHONE as the multivalued attribute that will be stored.
In this table, the attribute DESCRICAO_CURSO depends solely on the primary key.
COURSE_ID. Thus, the table is not in 2NF. To achieve this, a new table is created.
chamada CURSOS que tem como chave primária ID_CURSO e atributo DESCRICAO
thus removing the attribute DESCRICAO_CURSO from the ALUNOS_CURSOS table.
13
IT2018
dependencies from the other non-key columns and extract them to another table. Consider, as
example, the table EMPLOYEES below.
Example 2
1stNormalForm
A relation is in 1st Normal Form if and only if each row contains exactly one value for
each attribute Example (data related to a book order - non-normalized structure):
SecondNormalForm
A relation is in 2nd Normal Form if it is in the first and if all the descriptor attributes
depend on the totality of the candidate keys.
14
Computer Science 2018
3rdNormalForm
A relation is in the 3rd Normal Form if it is in the 2nd Normal Form and if there are no attributes
descriptors depending functionally on other descriptor attributes (that do not belong to
no candidate key).
This relational schema is in the 3rd Normal Form because there are no relationships.
transitive functional dependencies are in BCNF because each relation has a unique key
candidate
Example 3
According to 1NF, all occurrences of a record must contain the same number of fields.
1NF does not allow repetitions or fields that contain more than one value. Note the example:
15
Computer Science 2018
In this case, to achieve complete normalization, following the 1NF, we would have the following tables:
In this example, the phones were separated because there was a possibility of one of the records
having more than one phone, which, if registered in the same table, would cause the
"denormalization" of the data. As for the ZIP code, it is in a separate field from the Address.
as well as the Neighborhood and the records are, thus, in a nested form.
We can say that a table is in 2NF if it is in 1NF and all non-key attributes
keys were completely dependent on the primary key (dependent on the entire key and not just
on her part–in case of composite keys).
Understand: if the client's name already exists in the Clients table, then it is not necessary in the
tableAppointments. This is what the 2NF deals with, these anomalies, redundancies in the database.
16
Computer Science 2018
In fact, this is wrong, since the products are registered in another table (the table of
products) where, at the time of registration, we have already informed your name. The correct way would be like this:
Note that it is only necessary to reference the primary key (the code) of the product, and nothing more!
17
Computer Science 2018
Note that the value of the "Subtotal" column can (and should) be easily obtained through the
calculation of the value of the column Q
' uant' multiplied by the value of the column V
' alor_unit.' This would eliminate
from our table (from the table above) the column 'Subtotal', leaving it like this:
Exercises on normalization
1) Transform into 1NF, 2NF, and 3NF
18