1-amaliy mashg’ulot Mavzu : Ma’lumotlar bazasini loyixalash. Ma’lumotlar bazasi dasturini o’rnatish va sozlash (MySqul server, oracle Server, Microsoft Sql Server). Ma’lumotlar bazasini loyihalash mohiyat aloqa diogramasini qurish


Download 1.2 Mb.
Sana02.12.2023
Hajmi1.2 Mb.
#1779873
Bog'liq
1 . Abdulayev Shuxratjon Ma’lumotlar bazasi


1-amaliy mashg’ulot
Mavzu : Ma’lumotlar bazasini loyixalash. Ma’lumotlar bazasi dasturini o’rnatish va sozlash (MySqul server, oracle Server, Microsoft Sql Server). Ma’lumotlar bazasini loyihalash mohiyat aloqa diogramasini qurish . Relyatsion ma’lumotlar bazasini loyihalash
Maqsad: MySql dastur muhitida ma’lumtlar bazasini loyihalashni o’rganish . Relaksion malumotlar bazasini tuzish


talabalar




talabalar

id

familya ism

tugulgan kun

manzili

guruh_id




id

int

primary key

1











2











3











4













guruhlar










guruhlar




id

guurh nomi

oqituvchi_id










id

int

pk













guruh nomi

varchar(50)












































(













Oqituvchi




id

familya ism













id

int

pk



































































Xulosa :
Men ushbu amaliy mashg’ulot tayorlash davomida My Sql dasturlash muxitini ornatish va malumotlarb bazasini loyihalashni o’rgandim . Ushbu loyihada Ki Yani kampiyuter Injinering fakultedini talabar malumotlarini saqlashni organdik .

2-amaliy mashg’ulot
Mavzu : Ma’lumotlar bazasini yaratish . SQL tilida jadvalar yaratish , o’zgartirish va o’chirish . Ma’lumotlarin tanlash va ular ustida amalar . AND , OR , NOT mantiqiy standart so’zlardan foydalanish . Ma’lumotlar saralash . Where standart sozida foydalanish
Maqsad: Jadvalr ustidda amalar. Ma’lumotni saqlash . AND , OR , NOT kodlarini ishlatish.
Sug'urta kompaniyasi
Kodlar
mysql> create database sugurta;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;


+-----------------------+
| Database |
+-----------------------+
| information_schema |
| idora |
| kutubxona |
| lombard |
| masulyatni_taqsimlash |
| mysql |
| sayohat_kompaniyasi |
| sugurta |
| test |
+-----------------------+
9 rows in set (0.01 sec)

mysql> use sugurta;


Database changed
mysql> create table shartnomalar(
-> id int auto_increment primary key ,
-> sana date,
-> summasi varchar(100),
-> tarif_stavkasi varchar(100));
Query OK, 0 rows affected (0.02 sec)

mysql> drop table shartnomalar;


Query OK, 0 rows affected (0.00 sec)

mysql> create table shartnomalar(


-> id int auto_increment primary key ,
-> sana date,
-> summasi varchar(100),
-> tarif_stavkasi varchar(100),
-> filial_kodi int,
-> sugurta_kodi int);
Query OK, 0 rows affected (0.00 sec)

mysql> create table sugurta_turi(


-> id int auto_increment primary key,
-> ism varchar(30));
Query OK, 0 rows affected (0.02 sec)

mysql> create table filial(


-> id int auto_increment primary key,
-> nomi varchar(40),
-> manzili varchar(40),
-> telefoni varchar(45));
Query OK, 0 rows affected (0.01 sec)

mysql> show tables ;


+-------------------+
| Tables_in_sugurta |
+-------------------+
| filial |
| shartnomalar |
| sugurta_turi |
+-------------------+
3 rows in set (0.00 sec)

mysql> desc filial;


+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| nomi | varchar(40) | YES | | NULL | |
| manzili | varchar(40) | YES | | NULL | |
| telefoni | varchar(45) | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+
4 rows in set (0.02 sec)

mysql> desc shartnomalar;


+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| sana | date | YES | | NULL | |
| summasi | varchar(100) | YES | | NULL | |
| tarif_stavkasi | varchar(100) | YES | | NULL | |
| filial_kodi | int(11) | YES | | NULL | |
| sugurta_kodi | int(11) | YES | | NULL | |
+----------------+--------------+------+-----+---------+----------------+
6 rows in set (0.02 sec)

mysql> desc sugurta_turi;


+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| ism | varchar(30) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
2 rows in set (0.02 sec)

mysql> INSERT INTO sugurta_turi (ism) VALUES ('some_value');


Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO shartnomalar (sana, summasi, tarif_stavkasi, filial_kodi, sugurta_kodi)


-> VALUES ('2023-11-11', '1000', 'some_tariff', 1, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO filial (nomi, manzili, telefoni)


-> VALUES ('Filial Name', 'Filial Address', '123-456-7890');
Query OK, 1 row affected (0.00 sec)

mysql> select*from filial;


+----+-------------+----------------+--------------+
| id | nomi | manzili | telefoni |
+----+-------------+----------------+--------------+
| 1 | Filial Name | Filial Address | 123-456-7890 |
+----+-------------+----------------+--------------+
1 row in set (0.00 sec)

mysql> select*from shartnomalar;


+----+------------+---------+----------------+-------------+--------------+
| id | sana | summasi | tarif_stavkasi | filial_kodi | sugurta_kodi |
+----+------------+---------+----------------+-------------+--------------+
| 1 | 2023-11-11 | 1000 | some_tariff | 1 | 2 |
+----+------------+---------+----------------+-------------+--------------+
1 row in set (0.00 sec)

mysql> select*from sugurta_turi;


+----+------------+
| id | ism |
+----+------------+
| 1 | some_value |
+----+------------+
1 row in set (0.00 sec)









Xulosa
MySQL — bu eng mashhur va juda ko'p foydalaniladigan ma'lumotlar bazasini boshqarish tizimi(MBBT) hisoblanadi. Bu tizim juda katta ma'lumotlar bilan ishlash uchun yaratilmagan, aksincha biroz kichik hajmdagi bazalar bilan katta tezlikda ishlash uchun yaratilgan. Uning asosiy ishlash doirasi, saytlar hisoblanadi. Hozirgi kunda juda ko'p sayt va bloklarning ma'lumotlari aynan shu MBBT saqlanadi.

3-amaliy mashg’ulot
Mavzu : Ma’lumotlar bazasini uchun interfeys yaratish . Dasturlash tillari a ma’lumotlar bazasi yordamida oddiy interfeys yaratish .
Maqsad: Ma'lumotlar bazasini yaratish, Jadvallar yaratish, Satirlarga ma'lumotlarni kritish, Where, and, or, not Insert into , Value , Select , From kodlarini ishlatish

Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.51-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| ehtiyot_qismlari |
| idora |
| kutubxona |
| lombard |
| masulyatni_taqsimlash |
| mysql |
| sayohat_kompaniyasi |
| sugurta |
| test |
+-----------------------+
10 rows in set (0.00 sec)

mysql> use kutubxona;
Database changed
mysql> show tables;
+----------------------+
| Tables_in_kutubxona |
+----------------------+
| chiqarilgan_kitoblar |
| kitoblar |
| oquvchilar |
+----------------------+
3 rows in set (0.01 sec)

mysql> select*from kitoblar;
+----+-----------------+--------------------+-------------+-------------+-----------+
| id | nomi | muallifi | depozit | ijara_narxi | janr |
+----+-----------------+--------------------+-------------+-------------+-----------+
| 1 | Sherlock Holmes | Arthur Conan Doyle | Kutubxona 1 | 5000 | Detective |
+----+-----------------+--------------------+-------------+-------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM kitoblar WHERE ijara_narxi > 5000;
Empty set (0.00 sec)

mysql> SELECT * FROM kitoblar WHERE ijara_narxi > 4000;
+----+-----------------+--------------------+-------------+-------------+-----------+
| id | nomi | muallifi | depozit | ijara_narxi | janr |
+----+-----------------+--------------------+-------------+-------------+-----------+
| 1 | Sherlock Holmes | Arthur Conan Doyle | Kutubxona 1 | 5000 | Detective |
+----+-----------------+--------------------+-------------+-------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT column1, column2 FROM kitoblar WHERE janr = 'Detective' AND depozit = 'Kutubxona 1';
ERROR 1054 (42S22): Unknown column 'column1' in 'field list'
mysql> SELECT * FROM kitoblar WHERE janr = 'Detective' OR janr = 'Adventure';
+----+-----------------+--------------------+-------------+-------------+-----------+
| id | nomi | muallifi | depozit | ijara_narxi | janr |
+----+-----------------+--------------------+-------------+-------------+-----------+
| 1 | Sherlock Holmes | Arthur Conan Doyle | Kutubxona 1 | 5000 | Detective |
+----+-----------------+--------------------+-------------+-------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM kitoblar WHERE NOT janr = 'Romance';
+----+-----------------+--------------------+-------------+-------------+-----------+
| id | nomi | muallifi | depozit | ijara_narxi | janr |
+----+-----------------+--------------------+-------------+-------------+-----------+
| 1 | Sherlock Holmes | Arthur Conan Doyle | Kutubxona 1 | 5000 | Detective |
+----+-----------------+--------------------+-------------+-------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM kitoblar WHERE depozit = 'Kutubxona 1' UNION SELECT * FROM kitoblar WHERE depozit = 'Kutubxona 2';
+----+-----------------+--------------------+-------------+-------------+-----------+
| id | nomi | muallifi | depozit | ijara_narxi | janr |
+----+-----------------+--------------------+-------------+-------------+-----------+
| 1 | Sherlock Holmes | Arthur Conan Doyle | Kutubxona 1 | 5000 | Detective |
+----+-----------------+--------------------+-------------+-------------+-----------+
1 row in set (0.00 sec)

mysql> SELECT kitoblar.*, author_info.* FROM kitoblar JOIN author_info ON kitoblar.muallifi = author_info.author_name;
ERROR 1146 (42S02): Table 'kutubxona.author_info' doesn't exist
mysql>



Xulosa : Men ushbu amaliy mashg’ulotni bajarish davomida Ma'lumotlar bazasini yaratish, Jadvallar yaratish, Satirlarga ma'lumotlarni kritish, Where, and, or, not, like bilan ishlashni o’rgandim.
Download 1.2 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling