Quyidagi ma’lumotlar bazalarini relyatsion ko’rinishi hamda mysql
ma’lumotlar bazasi orqali code ko’rinishida yaratish.
Maktab(o’quvchilar,o’qituvchilar,fanlar..)
1-rasm.Maktab nomli ma’lumotlar bazasi va undagi jadvallar Bizda
shartga ko’ra School nomli mb yaratish va unda
o’quvchilar,o’qituvchilar,fanlar nomli jadvallar bo’lishi kerak. Demak,biz birinchi
bo’lib fanlar jadvalini yaratib olamiz
Table:Sciences
CREATE TABLE `sciences` (
`id` int NOT NULL,
`parent_id` int DEFAULT NULL,
`sciense_name` varchar(30) NOT NULL,
`sciense_about` text NOT NULL,
Primary Key(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
Keyingi yaratadigan jadvalimiz o’qituvchilar jadvali
2-rasm.Teachers jadvali
Table:Teachers
CREATE TABLE `Teachers` (
`id` int NOT NULL,
`name_surname` varchar(30) NOT NULL,
`position` varchar(30) NOT NULL,
`startwork_date` date NOT NULL,
Primary Key(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
Endi esa Teachers jadvaliga O’qituvchilarning ism-familyasi,lavozimi va
qachondan sih boshlagani haqida ma’lumotlar kiritamiz.
INSERT INTO `Teachers` (`id`, `name_surname`, `position`, `startwork_date`)
VALUES
(1, 'Elyor Muhammadov', 'Matematika fani o\'qituvchisi', '2019-09-20'),
(2, 'Gulnoza Jo\'rayeva', 'Fizika fani o\'qituvchisi', '2012-10-20'),
(3, 'Suxrob Haydarov', 'Kimyo fani o\'qituvchisi', '2021-12-05'),
(4, 'Qosim Abdullayev', 'Informatika fani o\'qituvchisi', '2021-03-20'),
(5, 'Nargiza Xo\'jayeva', 'Biologiya fani o\'qituvchisi', '2022-05-20');
Oxirgi yaratadigan jadvalimiz esa o’quvchilar jadvali
Table:Pupils
CREATE TABLE `Pupils` (
`id` int NOT NULL,
`full_name` varchar(30) NOT NULL,
`birthday_date` date NOT NULL,
`pupil_class` varchar(20) NOT NULL,
Primary Key(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
3-rasm.Pupils jadvali
Endi esa bu jadvalga ma’lumot kiritshimiz kerak.
INSERT INTO `Pupils` (`id`, `full_name`, `birthday_date`, `pupil_class`)
VALUES
(1, 'Fozilbek Yo\'ldoshev', '2005-09-21', '11-\'B\' sinf'),
(2, 'Iroda Qobilova', '2005-04-19', '10-\'A\' sinf'),
(3, 'Shavkat To\'rayev', '2006-12-20', '10-\'B\' sinf'), (4,
'Ahmad Tursunov', '2006-02-08', '10-\'V\' sinf'),
(5, 'Sardor Qahhorov', '2005-05-20', '11-\'A\' sinf');
Endi esa o’quvchilar haqida general_information nomli jadval yaratib unga
pupil_id,teachers_id va sciences_id ni FOREIGN KEY orqali ulashni ko’rib
chiqamiz.
CREATE TABLE `general_information` (
`id` int NOT NULL,
`pupil_name` varchar(20) NOT NULL,
`pupil_id` int NOT NULL,
`sciences_id` int NOT NULL,
`teacher_id` int NOT NULL
Primary Key(id),
FOREIGN KEY(pupil_id) REFERENCES Pupils(id),
FOREIGN KEY(sciences_id) REFERENCES sciences(id),
FOREIGN KEY(teacher_id) REFERENCES Teachers(id) );
4-rasm.general_information jadvali
Dostları ilə paylaş: |