O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNALOGIYALARI VA KOMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNALOGIYALARI UNIVERSITETI
“Ma‘lumotlar bazasini boshqarish”
fanidan bajargan
Labaratoriya ishi
Bajardi: Butunboyev Ahrorbek
Laboratoriya mavzulari:
1. Ma’lumotlar bazasining axborot mantiqiy modеlini qurish.
2. Rеlyatsion ma’lumotlar bazasini loyihalash.
3. Ma’lumotlarni qayta ishlashda mantiqiy ifodalardan foydalanish.
4. Ma’lumotlar bazasi jadvallarini modifikatsiyalash.
5. Ma’lumotlarni tanlash va saralash.
6. Standart funksiyalardan foydalanib so‘rovlar yaratish.
7. Murakkab so‘rovlar yaratish.
8. Bir nеchta jadvallar birlashtirish, «join» lar bilan ishlash.
1- LABORATORIYA ISHI
Mohiyat – aloqa diagrammasini qurish (ER modeli). Relyatsion ma`lumotlar bazasini loyihalash.
Ushbu labaratoriyada ma`limotlar bazasini loyihalash uchun mohiyat – aloqa modelini ishlab chiqish bo`yicha ko`nikmaga ega bo‘lish o‘rganiladi.
Vokzal
|
ID
|
Ketadigan yunalish
|
Ketish vaqti
|
Qaytadigan yunalish
|
Qaytish vaqti
|
1
|
Samarqand
|
15:00
|
Toshkent
|
17:00
|
2
|
Buxoro
|
13:00
|
Jizzax
|
19:00
|
3
|
Navoiy
|
10:00
|
Xorazm
|
20:00
|
4
|
Namangan
|
08:00
|
Qashqadaryo
|
14:00
|
5
|
Toshkent
|
09:00
|
Xorazm
|
20:00
|
Poyezdlar
|
|
|
ID
|
Nomi
|
Rangi
|
|
|
1
|
Express
|
Qizil
|
|
|
2
|
Afrosiyob
|
Oq
|
|
|
3
|
Aj
|
Yashil
|
|
|
4
|
|
|
|
|
5
|
|
|
|
|
Loyiha haqidagi axborot diagramma ko`rinishida rasmiylashtiriladi, buning uchun quyidagi belgilar kiritiladi: mohiyat turlari – to`rtburchak bilan, atributlar-ovallar bilan tasvirlanadi va ular mos mohiyatlar bilan yo`nalishsiz qirralar bilan bog`lanadi.
Mohiyat – aloqa modeli predmet sohani (PS) faqat aniq bir qismini akslantiradi. Bu holda uni lokal model deyiladi. PS haqida to`la axborotga ega bo`lish uchun uni etarli kengroq tekshirish zarur va oldingisini to`ldiradigan local modellar qurish kerak. Shundan so`ng lokal modellar birlashtirilib PS haqida bir butun kompozitsion tasvirga ega bo`lamiz.
2 - LABORATORIYA ISHI
Mavzu: SQL tilida jadvallar yaratish, o‘zgartirish va o‘chirish.
Postgresqlga kirganimizda birinchi o`rinda DATABASE yaratib olamiz.
Keyin jadval yaratib olamiz.
Jadval yaratildi.
Jadvalni uchirishda DROP TABLE dan foydalaniladi
Jadvalni to`ldirib chiqamiz.
Va jadval tayyor.
3 - LABORATORIYA ISHI
Mavzu: Ma’lumotlarni saralash. Where standart so‘zidan foydalanish. Group by da Order by standart so‘zlaridan foydalanib so‘rov yaratish.
ORDER BY bilan sartirofka qilib olamiz.
WHERE bilan uzimizga kerakligini ajratib olamiz.
AND bu har ikkalasida borlarini chiqazib beradi.
Bizada Samarqand va Buxoro ga ketadigan reys yuqligi uchun hech qanaqa jadval chiqmadi.
4 - LABORATORIYA ISHI
Mavzu: Bir nechta jadvallar birlashtirish, «Join» lar bilan ishlash.
Joinlar bilan ishlashda bizada 2 ta jadval kerak buladi va ularni birlashtiramiz.
Va bizda 2 ta jadvallar tayyor buldi.
Endlikda userslar yani vokzal jadvalidan birortasini id orqali poyezdlar id bilan bog`laymiz .
Vokzal ni 4- id bilan poyezdlarni 1 id sini bog`ladik.
Qolganlarini bog`lab chiqamiz. Lekin 1 ta poyezd 1 ta yunalishga bog`lanadi sababi UNIQUE dan foydalangan edik.
Hammasini bog`lab chiqdik .
Shu tariqa JOIN larni yani birlashtirishni amalga oshirdik.
5 - LABORATORIYA ISHI
Mavzu: Standart funksiyalardan foydalanib so‘rovlar yaratish. Agregat funksiyalardan foydalanish.
Function
|
Argument Type(s)
|
Return Type
|
Description
|
array_agg(expression)
|
any non-array type
|
array of the argument type
|
input values, including nulls, concatenated into an array
|
array_agg(expression)
|
any array type
|
same as argument data type
|
input arrays concatenated into array of one higher dimension (inputs must all have same dimensionality, and cannot be empty or null)
|
avg(expression)
|
smallint, int, bigint, real, double precision, numeric, or interval
|
numeric for any integer-type argument, double precision for a floating-point argument, otherwise the same as the argument data type
|
the average (arithmetic mean) of all non-null input values
|
bit_and(expression)
|
smallint, int, bigint, or bit
|
same as argument data type
|
the bitwise AND of all non-null input values, or null if none
|
bit_or(expression)
|
smallint, int, bigint, or bit
|
same as argument data type
|
the bitwise OR of all non-null input values, or null if none
|
bool_and(expression)
|
bool
|
bool
|
true if all input values are true, otherwise false
|
bool_or(expression)
|
bool
|
bool
|
true if at least one input value is true, otherwise false
|
count(*)
|
|
bigint
|
number of input rows
|
count(expression)
|
any
|
bigint
|
number of input rows for which the value of expression is not null
|
every(expression)
|
bool
|
bool
|
equivalent to bool_and
|
json_agg(expression)
|
any
|
json
|
aggregates values, including nulls, as a JSON array
|
jsonb_agg(expression)
|
any
|
jsonb
|
aggregates values, including nulls, as a JSON array
|
json_object_agg(name, value)
|
(any, any)
|
json
|
aggregates name/value pairs as a JSON object; values can be null, but not names
|
jsonb_object_agg(name, value)
|
(any, any)
|
jsonb
|
aggregates name/value pairs as a JSON object; values can be null, but not names
|
max(expression)
|
any numeric, string, date/time, network, or enum type, or arrays of these types
|
same as argument type
|
maximum value of expression across all non-null input values
|
min(expression)
|
any numeric, string, date/time, network, or enum type, or arrays of these types
|
same as argument type
|
minimum value of expression across all non-null input values
|
string_agg(expression, delimiter)
|
(text, text) or (bytea, bytea)
|
same as argument types
|
non-null input values concatenated into a string, separated by delimiter
|
sum(expression)
|
smallint, int, bigint, real, double precision, numeric, interval, or money
|
bigint for smallint or int arguments, numeric for bigint arguments, otherwise the same as the argument data type
|
sum of expression across all non-null input values
|
xmlagg(expression)
|
xml
|
xml
|
concatenation of non-null XML values (see also Section 9.14.1.7)
|
Endilikda tayyor jadval orqali kup ishlatiladigan Aggregate funksiyalarigan foydalanamiz.
Shu jadval orqali ishlatib kuramiz.
Max() funksiyasi eng katta qiymatni chiqarib beradi
Min() funksiyasi eng kichik qiymatni chiqarib beradi
AVG() funksiyasi eng katta va eng kichik qiymatni o`rtachasini chiqarib beradi
ROUND(AVG()) funksiyasi butun qiymatni chiqarib beradi.
6 - LABORATORIYA ISHI
Mavzu: Murakkab so‘rovlar yaratish. Tasavvur, VIEW yaratish va undan foydalanish.
Hozir biz bitta murakkab so`rov yaratamiz. Buning uchun bizga INNER JOIN dan foydalanamiz.
Endilikda shuni ustun shaklida chiqaramiz “\x “ orqali.
Postgresqlda VIEW yaratishda bizga uzining PgAdmin tayyor interfeysi kerek bo`ladi.
Dostları ilə paylaş: |