0% 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.

Uploaded by

suyashjagtap692
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% 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.

Uploaded by

suyashjagtap692
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Enter password: ********

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 13
Server version: 8.0.41 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

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

mysql> create database suyash;


Query OK, 1 row affected (0.01 sec)

mysql> use suyash;


Database changed
mysql> CREATE TABLE institute (institute_id INT PRIMARY KEY,name
VARCHAR(255) NOT NULL,address VARCHAR(255) NOT NULL,contact_number
VARCHAR(100),email VARCHAR(100));
Query OK, 0 rows affected (0.04 sec)

mysql> CREATE TABLE students (student_id INT PRIMARY KEY, first_name


VARCHAR(100) NOT NULL,last_name VARCHAR(100),date_of_birth DATE,gender
CHAR(255),email VARCHAR(100),contact_number VARCHAR(15),address
VARCHAR(255),institute_id INT,FOREIGN KEY (institute_id) REFERENCES
institute(institute_ID));
Query OK, 0 rows affected (0.09 sec)

mysql> describe students;


+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| student_id | int | NO | PRI | NULL | |
| first_name | varchar(100) | NO | | NULL | |
| last_name | varchar(100) | YES | | NULL | |
| date_of_birth | date | YES | | NULL | |
| gender | char(255) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
| contact_number | varchar(15) | YES | | NULL | |
| address | varchar(255) | YES | | NULL | |
| institute_id | int | YES | MUL | NULL | |
+----------------+--------------+------+-----+---------+-------+
9 rows in set (0.00 sec)

mysql> CREATE TABLE trades (trade_id INT PRIMARY KEY,trade_name


VARCHAR(255) NOT NULL,description TEXT);
Query OK, 0 rows affected (0.04 sec)
mysql> CREATE TABLE enrollments (enrollment_id INT PRIMARY KEY, student_id
INT,trade_id INT,enrollment_date DATE,completion_date DATE, status
VARCHAR(50), FOREIGN KEY (student_id) REFERENCES students(student_id),
FOREIGN KEY (trade_id) REFERENCES trades(trade_id));
Query OK, 0 rows affected (0.10 sec)

mysql> INSERT INTO institute(institute_id,name,address,contact_number,email)


VALUES (410,'MJP ITI','yeola',5758952135,'[email protected]');
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (101,'suyash','jagtap','2007-03-
07','M','[email protected]','yeola',410);
Query OK, 1 row affected (0.05 sec)

mysql> select * from institute;


+--------------+---------+---------+----------------+---------------------+
| institute_id | name | address | contact_number | email |
+--------------+---------+---------+----------------+---------------------+
| 410 | MJP ITI | yeola | 5758952135 | [email protected] |
+--------------+---------+---------+----------------+---------------------+
1 row in set (0.00 sec)

mysql> select * from students;


+------------+------------+-----------+---------------+--------+---------------------------
+----------------+---------+--------------+
| student_id | first_name | last_name | date_of_birth | gender | email
| contact_number | address | institute_id |
+------------+------------+-----------+---------------+--------+---------------------------
+----------------+---------+--------------+
| 101 | suyash | jagtap | 2007-03-07 | M |
[email protected] | NULL | yeola | 410 |
+------------+------------+-----------+---------------+--------+---------------------------
+----------------+---------+--------------+
1 row in set (0.00 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (102,'Rohan','pawar','2006-05-
21','M','[email protected]','Khadala',410);INSERT INTO
students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (103,'mohini','chaukade','2009-06-
07','f','[email protected]','vaijapur',410);
Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (104,'janardhan','deokar','2005-11-
21','M','[email protected]','shrirasgaon',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (105,'mayur','dhivre','2008-02-
06','M','[email protected]','shirur',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (106,'shrikant','kudke','2006-05-
30','M','[email protected]','nagarsul',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (107,'om','shinde','2007-03-
12','M','[email protected]','yeola',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (108,'omkar','ghuge','2008-08-
09','M','[email protected]','kotamgaon',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (109,'ravindra','more','2003-10-
24','M','[email protected]','nategaon',410);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO
students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (110,'avishkar','shingare','2008-02-
14','M','[email protected]','nadgaon',410);
Query OK, 1 row affected (0.01 sec)

mysql> select * from students;


+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| student_id | first_name | last_name | date_of_birth | gender | email
| contact_number | address | institute_id |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| 101 | suyash | jagtap | 2007-03-07 | M |
[email protected] | NULL | yeola | 410 |
| 102 | Rohan | pawar | 2006-05-21 | M |
[email protected] | NULL | Khadala | 410 |
| 103 | mohini | chaukade | 2009-06-07 | f |
[email protected] | NULL | vaijapur | 410 |
| 104 | janardhan | deokar | 2005-11-21 | M |
[email protected] | NULL | shrirasgaon | 410 |
| 105 | mayur | dhivre | 2008-02-06 | M | [email protected]
| NULL | shirur | 410 |
| 106 | shrikant | kudke | 2006-05-30 | M |
[email protected] | NULL | nagarsul | 410 |
| 107 | om | shinde | 2007-03-12 | M | [email protected]
| NULL | yeola | 410 |
| 108 | omkar | ghuge | 2008-08-09 | M | [email protected]
| NULL | kotamgaon | 410 |
| 109 | ravindra | more | 2003-10-24 | M | [email protected]
| NULL | nategaon | 410 |
| 110 | avishkar | shingare | 2008-02-14 | M |
[email protected] | NULL | nadgaon | 410 |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
10 rows in set (0.00 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (111,'shubham','borade','2003-08-
19','M','[email protected]','shriasgaon',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (112,'atul','gadakh','2008-09-
16','M','[email protected]','bhingara',410);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO


students(student_id,first_name,last_name,date_of_birth,gender,email,address,ins
titute_id) VALUES (113,'samarth','jagtap','2009-10-
19','M','[email protected]','bhabulgaon',410);
Query OK, 1 row affected (0.01 sec)

mysql> select * from students;


+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| student_id | first_name | last_name | date_of_birth | gender | email
| contact_number | address | institute_id |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| 101 | suyash | jagtap | 2007-03-07 | M |
[email protected] | NULL | yeola | 410 |
| 102 | Rohan | pawar | 2006-05-21 | M |
[email protected] | NULL | Khadala | 410 |
| 103 | mohini | chaukade | 2009-06-07 | f |
[email protected] | NULL | vaijapur | 410 |
| 104 | janardhan | deokar | 2005-11-21 | M |
[email protected] | NULL | shrirasgaon | 410 |
| 105 | mayur | dhivre | 2008-02-06 | M | [email protected]
| NULL | shirur | 410 |
| 106 | shrikant | kudke | 2006-05-30 | M |
[email protected] | NULL | nagarsul | 410 |
| 107 | om | shinde | 2007-03-12 | M | [email protected]
| NULL | yeola | 410 |
| 108 | omkar | ghuge | 2008-08-09 | M | [email protected]
| NULL | kotamgaon | 410 |
| 109 | ravindra | more | 2003-10-24 | M | [email protected]
| NULL | nategaon | 410 |
| 110 | avishkar | shingare | 2008-02-14 | M |
[email protected] | NULL | nadgaon | 410 |
| 111 | shubham | borade | 2003-08-19 | M |
[email protected] | NULL | shriasgaon | 410 |
| 112 | atul | gadakh | 2008-09-16 | M | [email protected]
| NULL | bhingara | 410 |
| 113 | samarth | jagtap | 2009-10-19 | M |
[email protected] | NULL | bhabulgaon | 410 |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
13 rows in set (0.00 sec)

mysql> describe institute;


+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| institute_id | int | NO | PRI | NULL | |
| name | varchar(255) | NO | | NULL | |
| address | varchar(255) | NO | | NULL | |
| contact_number | varchar(100) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> select * from institute;


+--------------+---------+---------+----------------+---------------------+
| institute_id | name | address | contact_number | email |
+--------------+---------+---------+----------------+---------------------+
| 410 | MJP ITI | yeola | 5758952135 | [email protected] |
+--------------+---------+---------+----------------+---------------------+
1 row in set (0.00 sec)

mysql> describe students;


+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| student_id | int | NO | PRI | NULL | |
| first_name | varchar(100) | NO | | NULL | |
| last_name | varchar(100) | YES | | NULL | |
| date_of_birth | date | YES | | NULL | |
| gender | char(255) | YES | | NULL | |
| email | varchar(100) | YES | | NULL | |
| contact_number | varchar(15) | YES | | NULL | |
| address | varchar(255) | YES | | NULL | |
| institute_id | int | YES | MUL | NULL | |
+----------------+--------------+------+-----+---------+-------+
9 rows in set (0.00 sec)

mysql> select * from students;


+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| student_id | first_name | last_name | date_of_birth | gender | email
| contact_number | address | institute_id |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
| 101 | suyash | jagtap | 2007-03-07 | M |
[email protected] | NULL | yeola | 410 |
| 102 | Rohan | pawar | 2006-05-21 | M |
[email protected] | NULL | Khadala | 410 |
| 103 | mohini | chaukade | 2009-06-07 | f |
[email protected] | NULL | vaijapur | 410 |
| 104 | janardhan | deokar | 2005-11-21 | M |
[email protected] | NULL | shrirasgaon | 410 |
| 105 | mayur | dhivre | 2008-02-06 | M | [email protected]
| NULL | shirur | 410 |
| 106 | shrikant | kudke | 2006-05-30 | M |
[email protected] | NULL | nagarsul | 410 |
| 107 | om | shinde | 2007-03-12 | M | [email protected]
| NULL | yeola | 410 |
| 108 | omkar | ghuge | 2008-08-09 | M | [email protected]
| NULL | kotamgaon | 410 |
| 109 | ravindra | more | 2003-10-24 | M | [email protected]
| NULL | nategaon | 410 |
| 110 | avishkar | shingare | 2008-02-14 | M |
[email protected] | NULL | nadgaon | 410 |
| 111 | shubham | borade | 2003-08-19 | M |
[email protected] | NULL | shriasgaon | 410 |
| 112 | atul | gadakh | 2008-09-16 | M | [email protected]
| NULL | bhingara | 410 |
| 113 | samarth | jagtap | 2009-10-19 | M |
[email protected] | NULL | bhabulgaon | 410 |
+------------+------------+-----------+---------------+--------+------------------------------
+----------------+-------------+--------------+
13 rows in set (0.00 sec)

mysql> describe trades;


+-------------+--------------+------+-----+---------+-------+
| 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)

mysql> insert into


enrollments(enrollment_id,student_id,trade_id,enrollment_date,completion_date
,status)VALUES('102','102','1002','2225-08-21','2019-04-07','uncomplet');
Query OK, 1 row affected (0.01 sec)
mysql>

You might also like