You are on page 1of 34

Faculty of Digital Transformations

Department of Information Systems

Course: BDIS 2209 «Data and information management»


Major: 5B07300 «Information Systems»

Naizabayeva Lyazat Kydyrgalievna Muratova Kamila Nurlanovna


Associate Professor, Lecturer,
Doctor of Technical Science Master in Technical Science

2021-2022

1
Lecture_2 Data Model
Classic models:
• Hierarchical
• Network
• Relational
• Post-relational
• Multidimensional
• Object-oriented

SQL operators:
• Group by etc.
.
• Subqueries

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
DATA MODEL
• All data has a certain logical structure
• Data models are a description of how data is stored in a
database.

Models can be divided into two types:


• object-oriented;
• record-based logical models.

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Hierarchical model

The main advantages of the hierarchical model:


• Efficient use of computer memory
• Quite good indicators of the execution time of the main operations
• The model is convenient for working with a hierarchically ordered
information
The main disadvantages of the hierarchical model are:
• Cumbersome to process information with sufficient complex logical
connections
• Difficulty understanding for an ordinary user

EXAMPLES of DBMS hierarchical model:


• IMS, PC / Focus, Team-Up and Data Edge,
• Oka, INES and MIRIS

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Network Model

The main advantages of the network model:


• Possibility of effective implementation by indicators memory
and efficiency costs
• (Compared to hierarchical) great opportunities in the sense
of the admissibility of the formation of arbitrary connections

The main disadvantages of the network model:


• High complexity and rigidity of the DB schema
• Difficulty to understand and perform processing information
in the database by an ordinary user

Well-known network DBMS:


• IDMS, db_VistaIII,
• NETWORK, CETOR and COMPASS

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Post-relational model
• The classical relational model assumes indivisibility
data stored in the fields of table records.
• The postrelation data model allows multi-valued
fields - fields, values which consist of subvalues.
Post-relational model
The main advantages of the post-relational model:
• Ability to represent a set of related relational tables with one
post-relational table, therefore - the clarity of the presentation
of information and increasing the efficiency of its processing

The main disadvantages of the post-relational model:


• The complexity of solving the problem of ensuring the integrity
and consistency of stored data.

• The post-relational data model we have considered is supported


by the uniVers DBMS. Other DBMSs based on the post-
relational model include Bubba and Dasdb.

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Example of relational Model Example of post-relational model
б) INVOICES
INVNO CUSTNO GOODS QTY
a) INVOICES

INVNO CUSTNO 0373 8723 cheese 3


0373 8723
fish 2
8374 8232
8374 8232 lemonade 1
7364 8723
juice 6

INVOICE.ITEMS cookies 2

INVNO GOODS QTY 7364 8723 yogurt 1

0373 cheese 3
а) SELECT INVOICES.INVNO, CUSTNO, GOODS, QTY
0373 fish 2
FROM INVOICES, INVOICE.ITEMS
8374 lemonade 1 WHERE INVOICES.INVNO=INVOICE.ITEMS.INVNO;

8374 juice 6 б) SELECT * FROM INVOICES;

8374 cookies 2

7364 yogurt 1
IITU, Course «Database in Information Systems»
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Multidimensional model
• 1993 E. Codd.

OLAP class (OnLine Analytical Processing):


• operational (transactional) processing
systems;
• analytical processing systems (decision
support systems).
An example of a relational
representation of the volume of
car sales
Multidimensional representation
model month volume
model June July August
BMW June 12

BMW July 24 BMW 12 24 5

BMW August 5 Audi 2 18 NULL


Audi June 2 Mazda NULL 19 NULL
Audi July 18
Mazda July 19

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Multidimensional model
The main advantages of the multidimensional model
• Convenience and efficiency of analytical processing of large
amounts of time-related data (In rel.m. - non-linear growth in the
complexity of operations)
The main disadvantages of the multivariate model
• Cumbersome for the simplest tasks of ordinary operational
information processing

EXAMPLES of DBMS multidimensional model


• Essbase (Arbor Software), Media Multi-matrix (Speedware),
• Oracle Express Server (Oracle) and Cache (InterSystems)
• Relational + multidimensional model: Media / MR (Speedware)
• Multidimensional + Object + Relational Model: Cache

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Object oriented model

• The structure of an object-oriented database is


graphically represented as a tree, the nodes of
which are objects.
• The properties of objects are described by some
standard type (for example, a string type) or a user-
constructed type (defined as a class).

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
The relational model
• Relational DBs were launched in 1970 with the publication of the article "A
Relational Model of Data for Large Shared Databanks" by E.F. Codd.
• Codd defined the basis for relational DB theory, and provided the set-
theoretic relational algebra for manipulating such DBs.
• Relational DBMSs largely won the competition for the DBMS layer, and
most popular DB products.
• Data structure in an RDBMS.

domain NAME domain STATUS


domain ID
domain ADDRESS attributes
The
primary
key COD NAME ADDRESS STATUS

S24 20 tuples
Anthony Sipleys, 120

S51 Derr Golflink, 641 10

S52 Kerry Seydend, 72/42 15

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Relational Model

• ADVANTAGES relational model


Simplicity, ease the physical implementation on a computer Processing
efficiency

• DISADVANTAGES relational model


Lack of standard means of identification of individual records
Complexity of the description of hierarchical and network links

Examples of relational database model:


• dBaseIIIPlus and dBaseIY (Ashton-Tate), DB2 (IBM), R: BASE
(Microrim), FoxPro early and FoxBase (Fox Software), Paradox и
dBASE for Windows (Borland, Visual FoxPro и Access (Microsoft),
Clarion (Clarion Software), Oracle, MS SQL Server
Object-relational: Oracle, MS SQL Server

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Object oriented model

The main advantages of OOM data in comparison with relational:


• Ability to display information about complex interrelationships of
objects
• OOM allows you to identify individual database records. And define the
functions of their processing
The main disadvantages of OOM:
• High conceptual complexity
• Inconvenience of data processing and low speed of execution requests
OOM DBMS EXAMPLES
• POET (POET Software), Jasmine (Computer Associates), Versant
• (Versant Technologies), 02 (Ardent Software), ODB-Jupiter
• (scientific production center "IntellekPlus"), Iris, Orion and Postgres.

IITU, Course «Database in Information Systems»


Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SQL operators. DDL
• CREATE OBJECT objectname
• CREATE DATABASE University
• CREATE TABLE TableName (
Column1 datatype optional_constraints,
Column2 datatype optional_constraints,
Column3 datatype optional_constraints,
...
);
WHERE:
TableName - the name of the table
Column1, etc - column names
datatype is the data type that is specified for most columns.
optional_constraints - an optional list of constraints that are applied to this column.
IITU, Course «Database in Information Systems»
16
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
CONSTRAINTS
• NOT NULL – a constraint that says that this column cannot be empty
(NULL), it must have a value

• PRIMARY KEY adds a primary key constraint to a column, it is good


practice to indicate in each table the column that contains the
primary key.

• IDENTITY is a constraint that automatically increments by 1 and


inserts a new value when a new row is added to the table. IDENTITY =
IDENTITY (1,1) also means that the account starts with one and when
a new row is inserted, the value will increase by 1 (1,2,3,4 ...)

• DEFAULT - you can set the default column value when no other value
was specified

IITU, Course «Database in Information Systems»


17
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
The most used data types

IITU, Course «Database in Information Systems»


18
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
The most used data types

IITU, Course «Database in Information Systems»


19
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
The most used data types

IITU, Course «Database in Information Systems»


20
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SQL operators. DDL
• DROP DATABASE DatabaseName
• DROP TABLE TableName
• ALTER - changing objects
- add a column to the table
ALTER TABLE table_name ADD column_name datatype;
- delete a column in a table
ALTER TABLE table_name DROP column column_name;
- change data type in the table column
ALTER TABLE table_name ALTER COLUMN column_name datatype;
- add constraints to a column
ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint
(column_name);
IITU, Course «Database in Information Systems»
21
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Example of creating table
C R E A T E T A B L E [Track]
(
[TrackId] INT NOT NULL IDENTITY PRIMARY KEY,
[Name] NVARCHAR(200) NOT NULL,
[AlbumId] INT,
[MediaTypeId] INT NOT NULL,
[GenreId] INT,
[Composer] NVARCHAR(220),
[Milliseconds] INT NOT NULL,
[Bytes] INT,
[UnitPrice] NUMERIC(10,2) NOT NULL
);
ALTER TABLE Track ADD FOREIGN KEY [AlbumID] REFERENCES Album[AlbumID]

IITU, Course «Database in Information Systems»


22
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SQL operators. DML
-add value to the table
INSERT INTO TableName (Column1, Column2, Column3, ...) VALUES(Value1,
Value2, Value3, ...);

-updating the records in the table


UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
-deleting the records from the table
DELETE FROM table_name
DELETE FROM table_name WHERE condition
-WHERE object is used to filter by condition
SELECT column1, column2, ... FROM table_name WHERE condition;
IITU, Course «Database in Information Systems»
23
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
WHERE and comparison operators

IITU, Course «Database in Information Systems»


24
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
WHERE and logical operators

IITU, Course «Database in Information Systems»


25
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
IITU, Course «Database in Information Systems»
26
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
GROUP BY object
-Used to group multiple rows by one or more columns
-Always used together with aggregation functions

SELECT column_name(s), aggregation_function() as Alias


FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition

IITU, Course «Database in Information Systems»


27
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
GROUP BY

IITU, Course «Database in Information Systems»


28
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
WHERE vs HAVING
• WHERE filters query BEFORE • HAVING filters the query AFTER
grouping grouping
• WHERE is used in conjunction • HAVING is only used in
with Select, Insert, Update conjunction with Select
• Aggregation functions can NOT • Aggregation functions MAY be
be used in WHERE clause, except used in the HAVING clause
when using subquery

IITU, Course «Database in Information Systems»


29
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
ORDER BY
Sort Ascending
SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC

Sort descending
SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) DESC

IITU, Course «Database in Information Systems»


30
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SUBQUERIES
SUBQUERY is a SQL query nested inside a larger query.
The subquery can be nested inside a SELECT, INSERT, UPDATE, or
DELETE statement or inside another subquery.
You can use the comparison operators, such as >, <, or =. The
comparison operator can also be a multiple-row operator, such as IN,
ANY, or ALL.

IITU, Course «Database in Information Systems»


31
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SUBQUERIES
There are a few rules that subqueries must follow:
• Subqueries must be enclosed within parentheses.
• A subquery can have only one column in the SELECT clause, unless multiple
columns are in the main query for the subquery to compare its selected
columns.
• An ORDER BY command cannot be used in a subquery, although the main query
can use an ORDER BY. The GROUP BY command can be used to perform the
same function as the ORDER BY in a subquery.
• Subqueries that return more than one row can only be used with multiple value
operators such as the IN operator.
• The BETWEEN operator cannot be used with a subquery. However, the
BETWEEN operator can be used within the subquery.
IITU, Course «Database in Information Systems»
32
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
SUMMARY
In this lesson, you studied:
Classic models:
• Hierarchical
• Network
• Multidimensional
• Object-oriented
• Post-relational
• Relational

SQL operators:
• Group by etc.
• Subqueries

IITU, Course «Database in Information Systems»


33
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla
Next Lecture: Relational algebra
Data structure in an RDBMS
Relational algebra
Relational operators:
• select /sample/
• project
• cartesian /cross product/
• union
• intersection
• difference /subtraction/
• compound /left, right, full join/
• division
SQL operators: Right, Left, Full, Crosse Join.

IITU, Course «Database in Information Systems»


34
Professor Naizabayeva Lyazat, Lecturer Muratova Kamilla

You might also like