The document outlines the creation and management of a MySQL database named 'suyash', which includes tables for 'institute', 'students', 'trades', and 'enrollments'. It details the structure of these tables, including their fields and data types, as well as the insertion of records into the 'institute' and 'students' tables. The document also includes queries to retrieve and describe the data within these tables.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views
sql quiry
The document outlines the creation and management of a MySQL database named 'suyash', which includes tables for 'institute', 'students', 'trades', and 'enrollments'. It details the structure of these tables, including their fields and data types, as well as the insertion of records into the 'institute' and 'students' tables. The document also includes queries to retrieve and describe the data within these tables.
+-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | trade_id | int | NO | PRI | NULL | | | trade_name | varchar(255) | NO | | NULL | | | description | text | YES | | NULL | | +-------------+--------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
mysql> select * from trades;
Empty set (0.00 sec)
mysql> INSERT INTO trades(trade_id,trade_name,description) VALUES('1002',
'fitter', 'tudy drawings,plans,specifications and blueprints in order to fit,assemble and shape machinery parts and other equipment'); Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO trades(trade_id,trade_name,description) VALUES('1001',
'copa', 'This trade is one of the most popular trade in ITIs through out the India. Lot of trainees working as data entry operators in Government and Private Organisations and also in Industries'); Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO trades(trade_id,trade_name,description) VALUES('1003',
'welder', 'A Welder is a professional responsible for assembling pieces of metal or repairing damage in components using heavy machinery that emits high heat'); Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO trades(trade_id,trade_name,description) VALUES('1004',
'Electrician', 'The responsibilities include everything from designing, installing and repairing systems to maintaining them according to safety regulations'); Query OK, 1 row affected (0.01 sec)
mysql> select * from trades;
+----------+------------- +----------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------+ | trade_id | trade_name | description | +----------+------------- +----------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------+ | 1001 | copa | This trade is one of the most popular trade in ITIs through out the India. Lot of trainees working as data entry operators in Government and Private Organisations and also in Industries | | 1002 | fitter | tudy drawings,plans,specifications and blueprints in order to fit,assemble and shape machinery parts and other equipment | | 1003 | welder | A Welder is a professional responsible for assembling pieces of metal or repairing damage in components using heavy machinery that emits high heat | | 1004 | Electrician | The responsibilities include everything from designing, installing and repairing systems to maintaining them according to safety regulations | +----------+------------- +----------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------+ 4 rows in set (0.00 sec)
mysql> describe enrollments;
+-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | enrollment_id | int | NO | PRI | NULL | | | student_id | int | YES | MUL | NULL | | | trade_id | int | YES | MUL | NULL | | | enrollment_date | date | YES | | NULL | | | completion_date | date | YES | | NULL | | | status | varchar(50) | YES | | NULL | | +-----------------+-------------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> select * from enrollments;
Empty set (0.00 sec) mysql> insert into enrollments(enrollment_id,student_id,trade_id,enrollment_date,completion_date ,status)VALUES('101','410','1001','2220-07-03','2021-06-02','complet'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`suyash`.`enrollments`, CONSTRAINT `enrollments_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `students` (`student_id`)) mysql> mysql> insert into enrollment(enrollment_id,student_id,trade_id,enrollment_date,completion_date, status)VALUES('101','410','1001','2220-07-03','2021-06-02','complet'); ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> insert into enrollment(enrollment_id,student_id,trade_id,enrollment_date,completion_date, status)VALUES('101','410','1001','2220-07-03','2021-06-02','complet'); ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> insert into enrollment (enrollment_id,student_id,trade_id,enrollment_date,completion_date,status)VAL UES('101','410','1001','2220-07-03','2021-06-02','complet'); ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> insert into enrollment (enrollment_id,student_id,trade_id,enrollment_date,completion_date,status)VAL UES('101','410','1001','2020-07-03','2021-06-02','complet'); ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> insert into enrollment (enrollment_id,student_id,trade_id,enrollment_date,completion_date,status)VAL UES('101','410','1001','2020-07-03','2021-06-02','complet'); ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> describe enrollment; ERROR 1146 (42S02): Table 'suyash.enrollment' doesn't exist mysql> describe enrollments; +-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | enrollment_id | int | NO | PRI | NULL | | | student_id | int | YES | MUL | NULL | | | trade_id | int | YES | MUL | NULL | | | enrollment_date | date | YES | | NULL | | | completion_date | date | YES | | NULL | | | status | varchar(50) | YES | | NULL | | +-----------------+-------------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> insert into enrollments
(enrollment_id,student_id,trade_id,enrollment_date,completion_date,status) VALUES ('101','410','1001','2020-07-03','2021-06-02','complet'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`suyash`.`enrollments`, CONSTRAINT `enrollments_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `students` (`student_id`)) mysql> insert into enrollments(enrollment_id,student_id,trade_id,enrollment_date,completion_date ,status)VALUES('101','101','410','2020-07-03','2021-06-02','complet'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`suyash`.`enrollments`, CONSTRAINT `enrollments_ibfk_2` FOREIGN KEY (`trade_id`) REFERENCES `trades` (`trade_id`)) mysql> select * from enrollments; Empty set (0.00 sec)
mysql> insert into
enrollments(enrollment_id,student_id,trade_id,enrollment_date,completion_date ,status)VALUES('101','101','410','2020-07-03','2021-06-02','complet'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`suyash`.`enrollments`, CONSTRAINT `enrollments_ibfk_2` FOREIGN KEY (`trade_id`) REFERENCES `trades` (`trade_id`)) mysql> insert into enrollments(enrollment_id,student_id,trade_id,enrollment_date,completion_date ,status)VALUES('101','101','1001','2020-07-03','2021-06-02','complet'); Query OK, 1 row affected (0.01 sec)
mysql> select * from enrollments;
+---------------+------------+----------+-----------------+-----------------+---------+ | enrollment_id | student_id | trade_id | enrollment_date | completion_date | status | +---------------+------------+----------+-----------------+-----------------+---------+ | 101 | 101 | 1001 | 2020-07-03 | 2021-06-02 | complet | +---------------+------------+----------+-----------------+-----------------+---------+ 1 row in set (0.00 sec)