SlideShare a Scribd company logo
1 of 97
ISM LAB FILE
- BY VANSH GOEL
- BCOM (H) SECTION - C
- ENROLLMENT NO - 14817788820
1) Steps to Install MySQL
Step 1: Go to the official website of MySQL and scroll down. Then you will see an option to
choose the Operating System. Choose Windows.
Step 2: After that, you will see two options to Download. Choose the mysql-installer-web-
community.
• Once, you click on Download, you will be redirected to a page :In the page, just click on
the option of “No thanks, just start my download.” Once, you click on this option, you will
see that MySQL Installer is getting downloaded.
Step 3: After MySQL Installer gets downloaded, double click on it, and you will see that the
MySQL installer Community is getting installed. Once, it is downloaded you will see a
screen. In the dialog box, just check in in the radio button and accept the License Agreement.
After that, click on Next.
Step 4: In the next wizard, you have to choose the setup type. Basically, this is where you
choose which features you wish to install. Here choose the option Full and click on Next.
This option will install MySQL Server, MySQL Shell, MySQL Router, MySQL Workbench,
MySQL Connectors, documentation, samples and examples and much more.
Step 5: Once you click on Next, you might see that some features may fail to install due to
lack of requirements. So, either you can resolve them, or can skip them, by clicking on Next.
Next, you will see a dialog box asking for your confirmation of a few products not getting
installed. So, you can just click on Yes.
As soon as you click on Next, you will see the list of the products which will get installed. So,
if you are fine with the products, go ahead and click on Execute.
Once you hit on Execute, you will see that the products are getting installed.
Now, once the installation is complete, click on Next.
Next, you have to configure the Server and Router. So, in the dialog box, click on Next.
Step 6: In the below wizard, you can either choose the Standalone MySQL Replication or the
InnoDB Cluster based on your requirement and then click on Next.
Step 7: Once, you click on Next, you have to mention the server configuration and click on
next.
Step 8: Now, you have to choose the authentication method.
Step 9: Next, you have to mention the MySQL Root Password and again click on Next.
Step 10: Finally, you have to choose whether you want to start the server or not or leave it as
it is. Now, the wizard will give you a list of the configurations which will be applied. So, if
you agree with the configuration click on Execute. Once the execution is done, click on
Finish. This will finish the configuration of Server.
Step 11: In the next wizard that comes up, you can choose to configure the Router. So just
click on Next and click on Finish.
Step 12: Once, you click on Finish, you will see the following wizard, to Connect to server.
Here mention the root password, which you had set in the previous steps. Check if the
connection is successful, by clicking on the Check button and then click on Execute. Now,
once the configuration is complete click on Next.
Step 13: Once, you click on Next, choose the configurations applied and click on Execute.
After the configurations get applied, you will see a screen. So, here just click on Finish.
Step 14: Now, to check whether MySQL is installed or not, you can open the MySQL Shell
and mention the root password.
2) Types of SQL Commands
SQL commands are instructions. It is used to
communicate with the database. It is also used
to perform specific tasks, functions, and queries
of data.
SQL can perform various tasks like create a
table, add data to tables, drop the table, modify
the table, set permission for users.
Types of SQL Commands
There are five types of SQL commands: DDL,
DML, DCL, TCL, and DQL.
(1) Data Definition Language (DDL):
DDL changes the structure of the table like creating a table, deleting a table, altering a table,
etc. All the command of DDL are auto-committed that means it permanently save all the
changes in the database.
Here are some commands that come under DDL:
1) Create - It is used to create a new table in the database.
Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
2) Alter - It is used to alter the structure of the database. This change could be either to
modify the characteristics of an existing attribute or probably to add a new attribute.
Syntax:
To add a new column in the table
ALTER TABLE TABLE_NAME ADD COLUMN_NAME COLUMN-definition;
3) Drop - It is used to delete both the structure and record stored in the table.
Syntax:
DROP TABLE TABLE_NAME;
4) Truncate - It is used to delete all the rows from the table and free the space containing the
table.
Syntax:
TRUNCATE TABLE TABLE_NAME;
(2) Data Manipulation Language (DML):
DML commands are used to modify the database. It is responsible for all form of changes in
the database. The command of DML is not auto-committed that means it can't permanently
save all the changes in the database. They can be rollback.
Here are some commands that come under DML:
1) Select - This is the same as the projection operation of relational algebra. It is used to select
the attribute based on the condition described by WHERE clause.
Syntax:
SELECT expressions FROM TABLES WHERE conditions;
2) Insert - The INSERT statement is a SQL query. It is used to insert data into the row of a
table.
Syntax:
INSERT INTO TABLE_NAME (COL 1, COL 2, COL 3,.... COL N) VALUES (VALUE 1,
VALUE 2, VALUE 3, .... VALUE N);
3) Update - This command is used to update or modify the value of a column in the table.
Syntax:
UPDATE TABLE_NAME SET [COLUMN_NAME 1= VALUE 1,... COLUMN_NAME N
= VALUE N] [WHERE CONDITION]
4) Delete - It is used to remove one or more row from a table.
Syntax:
DELETE FROM TABLE_NAME [WHERE CONDITION];
(3) Data Control Language (DCL):
DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
1) Grant
2) Revoke
a) Grant: It is used to give user access privileges to a database.
b) Revoke: It is used to take back permissions from the user.
(4) Transaction Control Language (TCL):
TCL commands can only use with DML commands like INSERT, DELETE and UPDATE
only . These operations are automatically committed in the database that's why they cannot be
used while creating tables or dropping them.
Here are some commands that come under TCL:
1) Commit - Commit command is used to save all the transactions to the database.
Syntax:
COMMIT;
2) Rollback - Rollback command is used to undo transactions that have not already
been saved to the database.
Syntax:
ROLLBACK;
• Save Point - It is used to roll the transaction back to a certain point without rolling
back the entire transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
Constraints
i) Keys play an important role in the relational database.
ii) It is used to uniquely identify any record or row of data from the
table. It is also used to establish and identify relationships between
tables.
3) Keys in SQL
Types of Keys:
1) Super Key – A super key is a group of single or multiple keys which identifies rows in a table.
2) Primary Key – is a column or group of columns in a table that uniquely identify every row in that table.
Rules for defining Primary key:
• Two rows can’t have the same primary key value
• It must for every row to have a primary key value.
• The primary key field cannot be null.
• The value in a primary key column can never be modified or updated if any foreign key refers to that primary
key.
3) Candidate Key – is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key
with no repeated attributes.
4) Alternate Key – is a column or group of columns in a table that uniquely identify every row in that table.
5) Foreign Key – is a column that creates a relationship between two tables. The purpose of Foreign keys is to
maintain data integrity and allow navigation between two different instances of an entity.
6) Composite Key – is a combination of two or more columns that uniquely identify rows in a table. The
combination of columns guarantees uniqueness, though individual uniqueness is not guaranteed.
7) Unique Key - A unique key is a set of one or more than one fields/columns of a table that uniquely identify a
record in a database table. The unique key and primary key both provide a guarantee for uniqueness for a
column or a set of columns. There is an automatically defined unique key constraint within a primary key
constraint.
4) Integrity constraints in SQL
Types Of Constraints in MySQL:-
i. Not Null Constraints
ii. Unique Constraints
iii. Primary Key
iv. Foreign Key
v. Check Constraints
vi. Default Constraints
(i) Not Null Constraints
Add Not Null Constraint on Age Field in Persons
Table.
(ii) Unique Constraints
Alter Table Persons 1 Add Unique Constraints.
(iii) Primary key
Alter Table Persons 2 Add Primary Key.
(iv) Foreign Key
Alter Table Orders Add Foreign Key.
(v) Check Constraints
Alter Table Persons 3 Add Check Constraints.
(vi) Default Constraints
5) Create Database
6) Open Database
7) a) Create Tables (Persons)
7) b) Create Tables (Dept)
7) c) Create Tables (Project)
8) View Table Description using Desc (Persons)
9) a) View Table Description using Desc (Dept)
9) b) View Table Description using Desc (Project)
10) a) Insert Records (Persons 19 records + 1
Default record)
10) b) Insert Records (Dept - as given in Question)
10) c) Insert Records (Project - as given in Question)
11) Primary Key
) Primary Key
12) Foreign Key
13) a) Alter table and Check constraint (Add
Gender)
13) b) Add Gender after FName(Male, Female, Others)
13) c) Delete Column Pj_Duration from Project
Table
14) Rename table Project to April_Projects
15) Show Table Structure (Persons)
16) Update Table
Update P_id to 103 for Person whose Last Name is "Gupta“.
17) Delete Statement
• Delete the record of the person whose P_id is 101.
18) View all Records (Persons)
19) View Selective Records using where Clause
Display the details of persons whose department id is 1111.
20) View Selective Fields
Display P_id, FName & Salary of all Persons.
21) Select Distinct
List all the distinct City Names from Persons.
22) AND Operator
Display the details of persons whose reside is Delhi AND whose
Department ID is 1111.
23) OR Operator
Display the details of persons whose reside is Delhi OR whose
Department ID is 1111.
24) Order By Clause
a) Display the details of all the persons in ascending order of their
name.
24) Order By Clause
b) Display the details of all the persons in descending order of their
Department Ids.
25) LIKE Operator
a) Display the details of all the persons whose city name contains
the pattern "elh".
25) LIKE Operator
b) Display the details of all the persons whose second alphabet of
the name is 'a'.
25) LIKE Operator
c) Display the details of all the persons whose lastname starts with
'B' or 'S'.
25) LIKE Operator
d) Display the details of all the persons whose Last Name does not
start with 'B','S' or 'P’.
26) In Operator
Display the details of all the persons who reside in Delhi, Mumbai
or Kolkata.
27) Between Operator
Display the details of all the persons whose department id is
between 2 to 6.
28) View List of Databases
29) a) View list of tables in a database
29) b) Delete a Record
30) a) Drop Command
i) Delete a Database
30) b) Delete table April_Projects
31) SUM Function
Calculate the total salaries of all the persons whose Department ID
is 1111.
32) Group by Statement
Display D_id and Corresponding total salaries of all the
departments.
33) Having Clause
Display D_id and corresponding total salaries of all the
departments having total salaries greater than 30000.
34) Create Orders Table
35) AVG Function
Display the names of customers whose Order Price is greater than
the average Order Price from Orders table.
36) Count Function
Display the total number of records in orders table.
37) Count Distinct
Count Distinct Customers from Orders Table.
38) Max Function
Display the maximum Order Price from Orders table.
39) Min Function
Display the minimum Order Price from Orders table.
40) UCASE Function
Display the customer names from Orders table in capital letters or
uppercase.
41) LCASE Function
Display the customer names from Orders table in small letters or
lowercase.
42) MID Function
Display the first 3 alphabets of city from Persons table.
43) LEN Function
Display all the addresses along with their corresponding length
from Persons Table.
44) Cross Join
Perform Cartesian Product or Cross Join on Persons Table and
Dept Table.
45) Inner Join
Perform Inner Join on Persons Table and Dept Table.
46) Full Outer Join
Perform Full Outer Join on Persons Table and Dept Table.
47) Left Outer Join
Perform Left Outer Join on Persons Table and Dept Table.
48) Right Outer Join
Perform Right Outer Join on Persons Table and Dept Table.
Create Table Project 1 and Project 2.
49) Union
Create table Project1 and Project2 having attributes E_Id,
E_Name, Dept_Id)
50) Union All
Create table Project1 and Project2 having attributes E_Id,
E_Name, Dept_Id)
51) Commit

More Related Content

Similar to Vansh Goel ISM (1).pptx

Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 
Introduction to MySQL - Part 2
Introduction to MySQL - Part 2Introduction to MySQL - Part 2
Introduction to MySQL - Part 2
webhostingguy
 
Introduction to STATA(2).pdf
Introduction to STATA(2).pdfIntroduction to STATA(2).pdf
Introduction to STATA(2).pdf
Yomif3
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
sam2sung2
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
pradnyamulay
 

Similar to Vansh Goel ISM (1).pptx (20)

Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
 
Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019Upgrading to MySQL 8.0 webinar slides November 27th, 2019
Upgrading to MySQL 8.0 webinar slides November 27th, 2019
 
Module02
Module02Module02
Module02
 
Sql interview question part 8
Sql interview question part 8Sql interview question part 8
Sql interview question part 8
 
Ebook8
Ebook8Ebook8
Ebook8
 
IR SQLite Session #3
IR SQLite Session #3IR SQLite Session #3
IR SQLite Session #3
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
 
Database testing
Database testingDatabase testing
Database testing
 
Introduction to MySQL - Part 2
Introduction to MySQL - Part 2Introduction to MySQL - Part 2
Introduction to MySQL - Part 2
 
Introduction to STATA(2).pdf
Introduction to STATA(2).pdfIntroduction to STATA(2).pdf
Introduction to STATA(2).pdf
 
Db2 tutorial
Db2 tutorialDb2 tutorial
Db2 tutorial
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
My Sql Work Bench
My Sql Work BenchMy Sql Work Bench
My Sql Work Bench
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 

Recently uploaded

Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Valters Lauzums
 
一比一原版麦考瑞大学毕业证成绩单如何办理
一比一原版麦考瑞大学毕业证成绩单如何办理一比一原版麦考瑞大学毕业证成绩单如何办理
一比一原版麦考瑞大学毕业证成绩单如何办理
cyebo
 
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotecAbortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理
pyhepag
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptx
DilipVasan
 
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
pyhepag
 
一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理
pyhepag
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
pyhepag
 
Fuzzy Sets decision making under information of uncertainty
Fuzzy Sets decision making under information of uncertaintyFuzzy Sets decision making under information of uncertainty
Fuzzy Sets decision making under information of uncertainty
RafigAliyev2
 

Recently uploaded (20)

Slip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp ClaimsSlip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp Claims
 
AI Imagen for data-storytelling Infographics.pdf
AI Imagen for data-storytelling Infographics.pdfAI Imagen for data-storytelling Infographics.pdf
AI Imagen for data-storytelling Infographics.pdf
 
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
 
一比一原版麦考瑞大学毕业证成绩单如何办理
一比一原版麦考瑞大学毕业证成绩单如何办理一比一原版麦考瑞大学毕业证成绩单如何办理
一比一原版麦考瑞大学毕业证成绩单如何办理
 
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotecAbortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
 
2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理
 
Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)
 
Artificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdfArtificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdf
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptx
 
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
 
Supply chain analytics to combat the effects of Ukraine-Russia-conflict
Supply chain analytics to combat the effects of Ukraine-Russia-conflictSupply chain analytics to combat the effects of Ukraine-Russia-conflict
Supply chain analytics to combat the effects of Ukraine-Russia-conflict
 
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
一比一原版加利福尼亚大学尔湾分校毕业证成绩单如何办理
 
How I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prisonHow I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prison
 
一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
 
basics of data science with application areas.pdf
basics of data science with application areas.pdfbasics of data science with application areas.pdf
basics of data science with application areas.pdf
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancing
 
Easy and simple project file on mp online
Easy and simple project file on mp onlineEasy and simple project file on mp online
Easy and simple project file on mp online
 
Fuzzy Sets decision making under information of uncertainty
Fuzzy Sets decision making under information of uncertaintyFuzzy Sets decision making under information of uncertainty
Fuzzy Sets decision making under information of uncertainty
 

Vansh Goel ISM (1).pptx

  • 1. ISM LAB FILE - BY VANSH GOEL - BCOM (H) SECTION - C - ENROLLMENT NO - 14817788820
  • 2. 1) Steps to Install MySQL Step 1: Go to the official website of MySQL and scroll down. Then you will see an option to choose the Operating System. Choose Windows. Step 2: After that, you will see two options to Download. Choose the mysql-installer-web- community. • Once, you click on Download, you will be redirected to a page :In the page, just click on the option of “No thanks, just start my download.” Once, you click on this option, you will see that MySQL Installer is getting downloaded. Step 3: After MySQL Installer gets downloaded, double click on it, and you will see that the MySQL installer Community is getting installed. Once, it is downloaded you will see a screen. In the dialog box, just check in in the radio button and accept the License Agreement. After that, click on Next. Step 4: In the next wizard, you have to choose the setup type. Basically, this is where you choose which features you wish to install. Here choose the option Full and click on Next. This option will install MySQL Server, MySQL Shell, MySQL Router, MySQL Workbench, MySQL Connectors, documentation, samples and examples and much more.
  • 3. Step 5: Once you click on Next, you might see that some features may fail to install due to lack of requirements. So, either you can resolve them, or can skip them, by clicking on Next. Next, you will see a dialog box asking for your confirmation of a few products not getting installed. So, you can just click on Yes. As soon as you click on Next, you will see the list of the products which will get installed. So, if you are fine with the products, go ahead and click on Execute. Once you hit on Execute, you will see that the products are getting installed. Now, once the installation is complete, click on Next. Next, you have to configure the Server and Router. So, in the dialog box, click on Next. Step 6: In the below wizard, you can either choose the Standalone MySQL Replication or the InnoDB Cluster based on your requirement and then click on Next. Step 7: Once, you click on Next, you have to mention the server configuration and click on next. Step 8: Now, you have to choose the authentication method.
  • 4. Step 9: Next, you have to mention the MySQL Root Password and again click on Next. Step 10: Finally, you have to choose whether you want to start the server or not or leave it as it is. Now, the wizard will give you a list of the configurations which will be applied. So, if you agree with the configuration click on Execute. Once the execution is done, click on Finish. This will finish the configuration of Server. Step 11: In the next wizard that comes up, you can choose to configure the Router. So just click on Next and click on Finish. Step 12: Once, you click on Finish, you will see the following wizard, to Connect to server. Here mention the root password, which you had set in the previous steps. Check if the connection is successful, by clicking on the Check button and then click on Execute. Now, once the configuration is complete click on Next. Step 13: Once, you click on Next, choose the configurations applied and click on Execute. After the configurations get applied, you will see a screen. So, here just click on Finish. Step 14: Now, to check whether MySQL is installed or not, you can open the MySQL Shell and mention the root password.
  • 5. 2) Types of SQL Commands SQL commands are instructions. It is used to communicate with the database. It is also used to perform specific tasks, functions, and queries of data. SQL can perform various tasks like create a table, add data to tables, drop the table, modify the table, set permission for users. Types of SQL Commands There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
  • 6. (1) Data Definition Language (DDL): DDL changes the structure of the table like creating a table, deleting a table, altering a table, etc. All the command of DDL are auto-committed that means it permanently save all the changes in the database. Here are some commands that come under DDL: 1) Create - It is used to create a new table in the database. Syntax: CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]); 2) Alter - It is used to alter the structure of the database. This change could be either to modify the characteristics of an existing attribute or probably to add a new attribute. Syntax: To add a new column in the table ALTER TABLE TABLE_NAME ADD COLUMN_NAME COLUMN-definition;
  • 7. 3) Drop - It is used to delete both the structure and record stored in the table. Syntax: DROP TABLE TABLE_NAME; 4) Truncate - It is used to delete all the rows from the table and free the space containing the table. Syntax: TRUNCATE TABLE TABLE_NAME; (2) Data Manipulation Language (DML): DML commands are used to modify the database. It is responsible for all form of changes in the database. The command of DML is not auto-committed that means it can't permanently save all the changes in the database. They can be rollback.
  • 8. Here are some commands that come under DML: 1) Select - This is the same as the projection operation of relational algebra. It is used to select the attribute based on the condition described by WHERE clause. Syntax: SELECT expressions FROM TABLES WHERE conditions; 2) Insert - The INSERT statement is a SQL query. It is used to insert data into the row of a table. Syntax: INSERT INTO TABLE_NAME (COL 1, COL 2, COL 3,.... COL N) VALUES (VALUE 1, VALUE 2, VALUE 3, .... VALUE N); 3) Update - This command is used to update or modify the value of a column in the table. Syntax: UPDATE TABLE_NAME SET [COLUMN_NAME 1= VALUE 1,... COLUMN_NAME N = VALUE N] [WHERE CONDITION]
  • 9. 4) Delete - It is used to remove one or more row from a table. Syntax: DELETE FROM TABLE_NAME [WHERE CONDITION]; (3) Data Control Language (DCL): DCL commands are used to grant and take back authority from any database user. Here are some commands that come under DCL: 1) Grant 2) Revoke a) Grant: It is used to give user access privileges to a database. b) Revoke: It is used to take back permissions from the user. (4) Transaction Control Language (TCL): TCL commands can only use with DML commands like INSERT, DELETE and UPDATE only . These operations are automatically committed in the database that's why they cannot be used while creating tables or dropping them.
  • 10. Here are some commands that come under TCL: 1) Commit - Commit command is used to save all the transactions to the database. Syntax: COMMIT; 2) Rollback - Rollback command is used to undo transactions that have not already been saved to the database. Syntax: ROLLBACK; • Save Point - It is used to roll the transaction back to a certain point without rolling back the entire transaction. Syntax: SAVEPOINT SAVEPOINT_NAME;
  • 11. Constraints i) Keys play an important role in the relational database. ii) It is used to uniquely identify any record or row of data from the table. It is also used to establish and identify relationships between tables. 3) Keys in SQL
  • 12. Types of Keys: 1) Super Key – A super key is a group of single or multiple keys which identifies rows in a table. 2) Primary Key – is a column or group of columns in a table that uniquely identify every row in that table. Rules for defining Primary key: • Two rows can’t have the same primary key value • It must for every row to have a primary key value. • The primary key field cannot be null. • The value in a primary key column can never be modified or updated if any foreign key refers to that primary key. 3) Candidate Key – is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key with no repeated attributes. 4) Alternate Key – is a column or group of columns in a table that uniquely identify every row in that table. 5) Foreign Key – is a column that creates a relationship between two tables. The purpose of Foreign keys is to maintain data integrity and allow navigation between two different instances of an entity. 6) Composite Key – is a combination of two or more columns that uniquely identify rows in a table. The combination of columns guarantees uniqueness, though individual uniqueness is not guaranteed. 7) Unique Key - A unique key is a set of one or more than one fields/columns of a table that uniquely identify a record in a database table. The unique key and primary key both provide a guarantee for uniqueness for a column or a set of columns. There is an automatically defined unique key constraint within a primary key constraint.
  • 13. 4) Integrity constraints in SQL Types Of Constraints in MySQL:- i. Not Null Constraints ii. Unique Constraints iii. Primary Key iv. Foreign Key v. Check Constraints vi. Default Constraints
  • 14. (i) Not Null Constraints
  • 15. Add Not Null Constraint on Age Field in Persons Table.
  • 17. Alter Table Persons 1 Add Unique Constraints.
  • 19. Alter Table Persons 2 Add Primary Key.
  • 21. Alter Table Orders Add Foreign Key.
  • 23. Alter Table Persons 3 Add Check Constraints.
  • 27. 7) a) Create Tables (Persons)
  • 28. 7) b) Create Tables (Dept)
  • 29. 7) c) Create Tables (Project)
  • 30. 8) View Table Description using Desc (Persons)
  • 31. 9) a) View Table Description using Desc (Dept)
  • 32. 9) b) View Table Description using Desc (Project)
  • 33. 10) a) Insert Records (Persons 19 records + 1 Default record)
  • 34.
  • 35.
  • 36. 10) b) Insert Records (Dept - as given in Question)
  • 37.
  • 38. 10) c) Insert Records (Project - as given in Question)
  • 39.
  • 40. 11) Primary Key ) Primary Key
  • 42. 13) a) Alter table and Check constraint (Add Gender)
  • 43.
  • 44. 13) b) Add Gender after FName(Male, Female, Others)
  • 45. 13) c) Delete Column Pj_Duration from Project Table
  • 46.
  • 47. 14) Rename table Project to April_Projects
  • 48. 15) Show Table Structure (Persons)
  • 49. 16) Update Table Update P_id to 103 for Person whose Last Name is "Gupta“.
  • 50. 17) Delete Statement • Delete the record of the person whose P_id is 101.
  • 51. 18) View all Records (Persons)
  • 52. 19) View Selective Records using where Clause Display the details of persons whose department id is 1111.
  • 53. 20) View Selective Fields Display P_id, FName & Salary of all Persons.
  • 54. 21) Select Distinct List all the distinct City Names from Persons.
  • 55. 22) AND Operator Display the details of persons whose reside is Delhi AND whose Department ID is 1111.
  • 56. 23) OR Operator Display the details of persons whose reside is Delhi OR whose Department ID is 1111.
  • 57. 24) Order By Clause a) Display the details of all the persons in ascending order of their name.
  • 58. 24) Order By Clause b) Display the details of all the persons in descending order of their Department Ids.
  • 59. 25) LIKE Operator a) Display the details of all the persons whose city name contains the pattern "elh".
  • 60. 25) LIKE Operator b) Display the details of all the persons whose second alphabet of the name is 'a'.
  • 61. 25) LIKE Operator c) Display the details of all the persons whose lastname starts with 'B' or 'S'.
  • 62. 25) LIKE Operator d) Display the details of all the persons whose Last Name does not start with 'B','S' or 'P’.
  • 63. 26) In Operator Display the details of all the persons who reside in Delhi, Mumbai or Kolkata.
  • 64. 27) Between Operator Display the details of all the persons whose department id is between 2 to 6.
  • 65. 28) View List of Databases
  • 66. 29) a) View list of tables in a database
  • 67. 29) b) Delete a Record
  • 68. 30) a) Drop Command i) Delete a Database
  • 69. 30) b) Delete table April_Projects
  • 70. 31) SUM Function Calculate the total salaries of all the persons whose Department ID is 1111.
  • 71. 32) Group by Statement Display D_id and Corresponding total salaries of all the departments.
  • 72. 33) Having Clause Display D_id and corresponding total salaries of all the departments having total salaries greater than 30000.
  • 74.
  • 75. 35) AVG Function Display the names of customers whose Order Price is greater than the average Order Price from Orders table.
  • 76. 36) Count Function Display the total number of records in orders table.
  • 77. 37) Count Distinct Count Distinct Customers from Orders Table.
  • 78. 38) Max Function Display the maximum Order Price from Orders table.
  • 79. 39) Min Function Display the minimum Order Price from Orders table.
  • 80. 40) UCASE Function Display the customer names from Orders table in capital letters or uppercase.
  • 81. 41) LCASE Function Display the customer names from Orders table in small letters or lowercase.
  • 82. 42) MID Function Display the first 3 alphabets of city from Persons table.
  • 83. 43) LEN Function Display all the addresses along with their corresponding length from Persons Table.
  • 84. 44) Cross Join Perform Cartesian Product or Cross Join on Persons Table and Dept Table.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89. 45) Inner Join Perform Inner Join on Persons Table and Dept Table.
  • 90. 46) Full Outer Join Perform Full Outer Join on Persons Table and Dept Table.
  • 91.
  • 92. 47) Left Outer Join Perform Left Outer Join on Persons Table and Dept Table.
  • 93. 48) Right Outer Join Perform Right Outer Join on Persons Table and Dept Table.
  • 94. Create Table Project 1 and Project 2.
  • 95. 49) Union Create table Project1 and Project2 having attributes E_Id, E_Name, Dept_Id)
  • 96. 50) Union All Create table Project1 and Project2 having attributes E_Id, E_Name, Dept_Id)