Professional Documents
Culture Documents
Topic 7. Normalization of The Relational Data Model
Topic 7. Normalization of The Relational Data Model
HNEU,
Department of Information Systems,
Database Course,
V. V. Fedko
Contents
1. Anomalies when performing operations with
the database
2. Functional dependencies
3. Normal forms and normalization of relations
4. Denormalization of relations
Modification anomalies. When changing the manufacturer's address, appropriate corrections should be
made for all database tuples corresponding to this manufacturer.
Deletion anomalies. When deleting all tuples where there is a delivery from one manufacturer, the address
and name of the manufacturer are lost.
Insertion anomalies. When the contract was signed with the manufacturer, but there was no supply from
him. Then there will be undefined values in the table, since impossible to completely form a tuple.
Product_Sale
Sale_date Manufacturer_name Adrress Product_name Price Quantity
01.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Bread "Ukrainian" 13.50 200
01.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Long loaf "Milk" 12.80 250
01.09.2021 Bakery "Kulinichi" Kharkiv, st. Grishchenko, 17 Bun with poppy seeds 9.00 150
02.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Bread "Ukrainian" 13.50 220
02.09.2021 Bakery "Kulinichi" Kharkiv, st. Grishchenko, 17 Long loaf "Milk" 12.80 300
02.09.2021 Bakery “Poltava" Poltava, st. Kamarova, 10-A Bun with poppy seeds 9.00 100
Manufacturer Product
Manufacturer_name Adrress Product_name Price
Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Bread "Ukrainian" 13.50
Bakery "Kulinichi" Kharkiv, st. Grishchenko, 17 Long loaf "Milk" 12.80
Bakery “Poltava" Poltava, st. Kamarova, 10-A Bun with poppy seeds 9.00
HNEU, Department of Information Systems, Course Database, V. V. Fedko 7
Normalization mechanism
Normalization of relations consists in decomposing a relation
that is in a previous normal form into two or more relations
satisfying the requirements of the next normal form.
Advantages of normalization
Normalization allows:
1) to be sure that each attribute is defined for its entity;
2) significantly reduce the amount of memory for storing
information;
3) eliminate anomalies in the organization of data storage.
Product_Sale
Sale_date Manufacturer_name Adrress Product_name Price Quantity
01.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Bread "Ukrainian" 13.50 200
01.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Long loaf "Milk" 12.80 250
01.09.2021 Bakery "Kulinichi" Kharkiv, st. Grishchenko, 17 Bun with poppy seeds 9.00 200
02.09.2021 Bakery "Saltovsky" Kharkiv, st. Shironintsev, 1 Bread "Ukrainian" 13.50 220
02.09.2021 Bakery "Kulinichi" Kharkiv, st. Grishchenko, 17 Long loaf "Milk" 12.80 200
02.09.2021 Bakery “Poltava" Poltava, st. Kamarova, 10-A Bun with poppy seeds 9.00 100
A functional dependency is called trivial if and only if the right (dependent) part of the
symbol for this dependency is a subset of its left part (determinant).
(SaleId) → (Manufacturer_name)
(Manufacturer_name) ↛ (SaleId)
(Manufacturer_name) → (Address)
(SaleId) → (Address)
Manufacturer_Product _Price
Manufacturer_name Product_name Price
Bakery "Saltovsky" Bread "Ukrainian" 13.00
Bakery "Saltovsky" Long loaf "Milk" 13.00
Bakery "Saltovsky" Bread "Ukrainian" 12.00
Bakery "Saltovsky" Long loaf "Milk" 12.00
Bakery "Kulinichi" Bread "Ukrainian" 13.00
Manufacturer_Product _Price
Manufacturer_name Product_name Price
Bakery "Saltovsky" Bread "Ukrainian" 13.00
Bakery "Saltovsky" Long loaf "Milk" 12.00
R1 ∩ R2 ⟶ R 1 Bakery "Kulinichi" Bread "Ukrainian" 13.00
{Product_name, Price} ∩ {Product_name, Manufacturer_name} = {Product_name}
{Product_name} → {Product_name, Price}
HNEU, Department of Information Systems, Course Database, V. V. Fedko 18
Keys & dependencies
Product (ProductId, Product_name, Price, Purchase_price):
(ProductId) → (Product_name)
(ProductId) → (Price, Purchase_price)
(ProductId, Product_name) → (Price, Purchase_price)
Conclusion: If the determinant contains a primary key, then the set of all other
attributes of the relation functionally depends on it.
Manufacturer Manufacturer
Manufacturer_name Phones Manufacturer_name Phone
Bakery "Kulinichi" 057222222, 066222277 Bakery "Kulinichi" 057222222
Bakery “Poltava" 053666666 Bakery "Kulinichi" 066222277
Bakery “Poltava" 053666666
A relation is in the Boyce-Codd Normal Form (BCNF) if and only if every determinant is a
candidate key.
Applies when:
• the relationship may have two or more potential keys;
• potential keys may not be simple, but composite, that is, include several attributes;
• composite potential keys may overlap (have one or more common attributes).
Sometimes BCNF is also called 3.5 normal form.
4NF
A relation is in the Fourth Normal Form (4NF) if and only if for every nontrivial multi-valued
dependency A ↠ B, A is a candidate key of the relation.
5NF
A relation is in the Fifth Normal Form (5NF) if and only if for every join dependency (R1, R2, . . .
Rn) in a relation R, each projection includes a candidate key of the original relation.
HNEU, Department of Information Systems, Course Database, V. V. Fedko 26
4. Denormalization of relations
Purpose of denormalization
Denormalization is a strategy used on a previously-normalized database to increase
performance.
Denormalization is the process of trying to improve the read performance of a
database, at the expense of losing some write performance, by adding redundant
copies of data or by grouping data.
If efficiency is more important than flexibility and volume of the database,
denormalization can be performed - that is, inverse database conversion, in which
linked tables are joined for more efficient access.
Denormalization is performed when database normalization is performed completely
and correctly, and bottlenecks in the schema are identified, which can reduce the
efficiency of query execution.
DimDate
DateId
CalendarDate
CalendarYear
MonthNumberOfYear
DayNumberOfMonth
FactReceipts
ManufacturerId (FK) DimManufacturer
DimProduct DateId (FK) ManufacturerId
ProductId (FK)
ProductId ManufacturerName
Quantity CityName
ProductName
Cost RegionName
Price
PurchasePrice
ProductGroupName
HNEU, Department of Information Systems, Course Database, V. V. Fedko 28
Aggregate functions
Queries in which individual indicators are calculated based on information stored in the database, especially
when using groupings and aggregate functions (COUNT, MAX, SUM, etc.) are very often carried out for quite a
long time. As a result, the introduction of an additional column, which would contain the values that would
have been previously calculated, can significantly save time when executing a query, but requires timely
changes in the data in this column (stock balance).
InvoiceProduct
… Product
ProductId
Quantity ProductId
ProductName
Price
Sale PurchasePrice
… StockBalance
ProductId
Quantity