O‘ZBEKISTON RESPUBLIKASI
RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI NURAFSHON FILIALI
“Kompyuter injiniringi” fakulteti
Guruh nomi: 610-22.
F.I.SH: Ileshev Asadbek Alisher o’g’li.
Fan: Ma’lumotlar bazasi.
Mavzu: Relyatsion ma’lumotlar bazasini loyihalash.
Tekshirdi: Turg’unaliyev Shouhruz Abduno’mon o’g’li.
Amaliy mashg’ulot №2
Variant 6
Topshiriq. Fitness zali uchun taxminiy ma’lumotlar bazasi yarating.
Code:
CREATE DATABASE Asadbek
Code:
CREATE TABLE people(
id INT PRIMARY KEY AUTO_INCREMENT,
ism VARCHAR(50),
fam VARCHAR(50),
tel INT NOT NULL,
vazn INT NOT NULL
);
CREATE TABLE food(
id INT PRIMARY KEY AUTO_INCREMENT,
ratsion VARCHAR(100),
nomi VARCHAR(255) NOT NULL,
gramm VARCHAR(50) NOT NULL,
people_id INT
);
CREATE TABLE p_exercises(
id INT PRIMARY KEY AUTO_INCREMENT,
push_up INT NOT NULL,
squats INT NOT NULL,
run_mtr INT NOT NULL,
people_id INT
);
CREATE TABLE plan(
id INT PRIMARY KEY AUTO_INCREMENT,
top_body VARCHAR(100) NOT NULL,
middle_body VARCHAR(100) NOT NULL,
bottom_body VARCHAR(100) NOT NULL,
people_id INT
);
Code:
INSERT INTO people(ism, fam, tel, vazn)
VALUE("John","Williams", 10112545, 120),
("Antony", "Smith", 10025467, 60),
("Wiliam", "Wolse", 10253568, 96),
("Jonathan","Johnsons", 13257789, 76);
INSERT INTO food(ratsion, nomi, gramm)
VALUE("2 mahal", "vegetables", "200"),
("2 mahal", "meat dishes", "250"),
("1 mahal", "milk dishes", "150"),
("2 mahal", "fruits", "400");
INSERT INTO p_exercises(push_up, squats, run_mtr)
VALUES(25, 80, 1200),
(40, 100, 4000),
(50, 130, 3000),
(70, 150, 6000);
INSERT INTO plan(top_body, middle_body, bottom_body)
VALUES("Monday", "Wednesday", "Satarday"),
("Tuesday", "Thursday", "Saturday"),
("Wednesday", "Monday", "Saturday"),
("Wednesday", "Friday", "Monday");
Code:
ALTER TABLE food
ADD FOREIGN KEY (people_id) REFERENCES people(id);
ALTER TABLE plan
ADD FOREIGN KEY (people_id) REFERENCES people(id);
ALTER TABLE p_exercises
ADD FOREIGN KEY (people_id) REFERENCES people(id);
Natija:
Dostları ilə paylaş: |