Mavzu: Tasavvur, VIEWlar yaratish va undan foydalanish.
Ishdan maqsad: SQL da VIEWlar yaratish bo`yicha ko`nikmaga ega bo`lish.
Masalani qo`yilishi: Berilgan predmet soha ma`lumotlar bazasidagi barcha ob`yektlarni ustida VIEWlar yaratish asosida amallarini bajarish.
Uslubiy ko`rsatmalar: Shunday qilib, SQL-dagi VIEWlar odatdagi jadvallardan SELECT so'rovi orqali olingan ma'lumotlarni o'z ichiga olgan maxsus ob'ektdir. Bu virtual jadval bo'lib, unga oddiy jadvallar kabi kirish va saqlangan ma'lumotlarni olish mumkin. SQL ko'rinishida bitta jadval va ikkala jadvalning ikkala ma'lumotlari bo'lishi mumkin.
Create view
mysql> create view info_samalyot
-> as select parvozlar.samalyot, samalyotlar.orindiqlar_soni, samalyotlar.yuk_hajmi
-> from samalyotlar, parvozlar
-> where samalyotlar.sam_id = parvozlar.sam_id
-> ;
Query OK, 0 rows affected (0.16 sec)
mysql> show full tables;
+----------------------------+------------+
| Tables_in_aeroport | Table_type |
+----------------------------+------------+
| aeroport_hodimlari | BASE TABLE |
| chipta_savdosi_bayonnomasi | BASE TABLE |
| info_samalyot | VIEW |
| parvozlar | BASE TABLE |
| samalyot_ekipajlari | BASE TABLE |
| samalyotlar | BASE TABLE |
+----------------------------+------------+
6 rows in set (0.00 sec)
Use view
mysql> select * from info_samalyot;
+----------+-----------------+-----------+
| samalyot | orindiqlar_soni | yuk_hajmi |
+----------+-----------------+-----------+
| AB_73 | 150 | Ko`p |
| AB_69 | 180 | Ko`p |
| AZ_68 | 200 | Ko`p |
| AD_56 | 160 | Ko`p |
| AB_71 | 140 | Kam |
+----------+-----------------+-----------+
5 rows in set (0.01 sec)
mysql>
mysql> create view murakkab
-> as
-> select samalyotlar.sam_id, samalyotlar.ishlab_chiqarish_yili, parvozlar.samalyot, parvozlar.chiqish
-> from samalyotlar
-> join parvozlar on samalyotlar.sam_id = parvozlar.sam_id;
Query OK, 0 rows affected (0.08 sec)
mysql> show full tables;
+----------------------------+------------+
| Tables_in_aeroport | Table_type |
+----------------------------+------------+
| aeroport_hodimlari | BASE TABLE |
| chipta_savdosi_bayonnomasi | BASE TABLE |
| info_samalyot | VIEW |
| murakkab | VIEW |
| parvozlar | BASE TABLE |
| samalyot_ekipajlari | BASE TABLE |
| samalyotlar | BASE TABLE |
+----------------------------+------------+
7 rows in set (0.00 sec)
mysql> select * from murakkab
-> ;
+--------+-----------------------+----------+------------+
| sam_id | ishlab_chiqarish_yili | samalyot | chiqish |
+--------+-----------------------+----------+------------+
| 1 | 2000 | AB_73 | 01.02.2002 |
| 2 | 2000 | AB_69 | 04.03.2005 |
| 3 | 2000 | AZ_68 | 01.05.2006 |
| 4 | 2000 | AD_56 | 01.04.2007 |
| 5 | 2000 | AB_71 | 07.03.2021 |
+--------+-----------------------+----------+------------+
5 rows in set (0.00 sec)
Drop views
mysql> drop view murakkab;
Query OK, 0 rows affected (0.00 sec)
mysql> drop view info_samalyot;
Query OK, 0 rows affected (0.00 sec)
mysql> show full tables;
+----------------------------+------------+
| Tables_in_aeroport | Table_type |
+----------------------------+------------+
| aeroport_hodimlari | BASE TABLE |
| chipta_savdosi_bayonnomasi | BASE TABLE |
| parvozlar | BASE TABLE |
| samalyot_ekipajlari | BASE TABLE |
| samalyotlar | BASE TABLE |
+----------------------------+------------+
5 rows in set (0.00 sec)
mysql>
Foydalanilgan veb-saytlar.
https://muhaz.org/download/4--amaliy-mashgulot-mavzu-malumotlarni-tanlash-va-ular-ustida.doc
http://www.hozir.org/2-amaliy-ish-mavzu-malumotlarni-tanlash-va-ular-ustida-amallar-v2.html
http://azkurs.org/malumotlar-bazasi-mustaqil-ish.html?page=3
https://e-ibrary.namdu.uz/30%20%D0%A2%D0%B5%D1%85%D0%BD%D0%B8%D0%BA%D0%B0%20%D1%84%D0%B0%D0%BD%D0%BB%D0%B0%D1%80/informatika_9_uzb.pdf
https://ilmiy.bmti.uz/blib/files/80/B.%20Ergashev%20-%20Ma%60lumotlar%20bazasini%20boshqarish%20tizimlari.PDF
Dostları ilə paylaş: |