What is MySQL
MySQL, the most popular Open-Source SQL database management system, is developed, distributed, and supported by Oracle Corporation.
MySQL is a database management system
A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL Server.
Since computers are very good at handling large amounts of data, database management systems play a central role in computing, as standalone utilities, or as parts of other applications.
MySQL databases are relational.
A relational database stores data in separate tables rather than putting all the data in one big storeroom. The database structures are organized into physical files optimized for speed. The logical model, with objects such as databases, tables, views, rows, and columns, offers a flexible programming environment.
You set up rules governing the relationships between different data fields, such as one-to-one, one-to-many, unique, required, or optional, and “pointers” between different tables. The database enforces these rules, so that with a well-designed database, your application never sees inconsistent, duplicate, orphan, out-of-date, or missing data.
The SQL part of “MySQL” stands for “Structured Query Language”. SQL is the most common standardized language used to access databases. Depending on your programming environment, you might enter SQL directly (for example, to generate reports), embed SQL statements into code written in another language, or use a language-specific API that hides the SQL syntax.
SQL is defined by the ANSI/ISO SQL Standard. The SQL standard has been evolving since 1986 and several versions exist. In this manual, “SQL-92” refers to the standard released in 1992, “SQL:1999” refers to the standard released in 1999, and “SQL:2003” refers to the current version of the standard. We use the phrase “the SQL standard” to mean the current version of the SQL Standard at any time.
Database for MySQL Practice :
Open MySQL workbench in your system
Select any connection
Enter the following queries in your Editor
Studies table import: -
CREATE TABLE studies (PNAME varchar(20), INSTITUTE varchar(20),
COURSE varchar(20), COURSE_FEE int );
INSERT INTO studies
SELECT 'ANAND','SABHARI','PGDCA',4500 UNION ALL
SELECT 'ALTAF','COIT','DCA',7200 UNION ALL
SELECT 'JULIANA','BDPS','MCA',22000 UNION ALL
SELECT 'KAMALA','PRAGATHI','DCA',5000 UNION ALL
SELECT 'MARY','SABHARI','PGDCA ',4500 UNION ALL
SELECT 'NELSON','PRAGATHI','DAP',6200 UNION ALL
SELECT 'PATRICK','PRAGATHI','DCAP',5200 UNION ALL
SELECT 'QADIR','APPLE','HDCA',14000 UNION ALL
SELECT 'RAMESH','SABHARI','PGDCA',4500 UNION ALL
SELECT 'REBECCA','BRILLIANT','DCAP',11000 UNION ALL
SELECT 'REMITHA','BDPS','DCS',6000 UNION ALL
SELECT 'REVATHI','SABHARI','DAP',5000 UNION ALL
SELECT 'VIJAYA','BDPS','DCA',48000
Software table import: -
CREATE TABLE software (PNAME varchar(20), TITLE
varchar(20),DEVELOPIN varchar(20), SCOST decimal(10,2), DCOST int,
SOLD int);
INSERT INTO software
SELECT 'MARY','README','CPP',300, 1200, 84 UNION ALL
SELECT 'ANAND','PARACHUTES','BASIC',399.95, 6000, 43 UNION ALL
SELECT 'ANAND','VIDEO TITLING','PASCAL',7500, 16000, 9 UNION ALL
SELECT 'JULIANA','INVENTORY','COBOL',3000, 3500, 0 UNION ALL
SELECT 'KAMALA','PAYROLL PKG.','DBASE',9000, 20000, 7 UNION ALL
SELECT 'MARY','FINANCIAL ACCT.','ORACLE',18000, 85000, 4 UNION ALL
SELECT 'MARY','CODE GENERATOR','C',4500, 20000, 23 UNION ALL
SELECT 'PATTRICK','README','CPP',300, 1200, 84 UNION ALL
SELECT 'QADIR','BOMBS AWAY','ASSEMBLY',750, 3000, 11 UNION ALL
SELECT 'QADIR','VACCINES','C',1900, 3100, 21 UNION ALL
SELECT 'RAMESH','HOTEL MGMT.','DBASE',13000, 35000, 4 UNION ALL
SELECT 'RAMESH','DEAD LEE','PASCAL',599.95, 4500, 73 UNION ALL
SELECT 'REMITHA','PC UTILITIES','C',725, 5000, 51 UNION ALL
SELECT 'REMITHA','TSR HELP PKG.','ASSEMBLY',2500, 6000, 7 UNION ALL
SELECT 'REVATHI','HOSPITAL MGMT.','PASCAL',1100, 75000, 2 UNION ALL
SELECT 'VIJAYA','TSR EDITOR','C',900, 700, 6
Programmer table import: -
CREATE TABLE programmer (PNAME varchar(20), DOB date, DOJ date, GENDER
varchar(2), PROF1 varchar(20), PROF2 varchar(20), SALARY int);
INSERT INTO programmer
SELECT 'ANAND','1966-04-12','1992-04-21','M','PASCAL','BASIC',3200 UNION ALL
SELECT 'ALTAF','1964-06-02','1990-11-13','M','CLIPPER','COBOL',2800 UNION ALL
SELECT 'JULIANA','1960-01-29','1990-04-21','F','COBOL','DBASE',3000 UNION ALL
SELECT 'KAMALA','1968-08-23','1992-01-02','F','C','DBASE',2900 UNION ALL
SELECT 'MARY','1970-06-24','1991-05-01','F','CPP','ORACLE',4500 UNION ALL
SELECT 'NELSON','1985-09-11','1989-08-11','M','COBOL','DBASE',2500 UNION ALL
SELECT 'PATTRICK','1965-11-10','1990-04-21','M','PASCAL','CLIPPER',2800 UNIONALL
SELECT 'QADIR','1965-06-23','1991-04-21','M','ASSEMBLY','C',3000 UNION ALL
SELECT 'RAMESH','1967-03-05','1991-08-22','M','PASCAL','DBASE',3200 UNION ALL
SELECT 'REBECCA','1967-01-01','1990-12-01','F','BASIC','COBOL',2500 UNION ALL
SELECT 'REMITHA','1970-04-08','1993-04-20','F','C','ASSEMBLY',3600 UNION ALL
SELECT 'REVATHI','1969-02-12','1992-01-02','F','PASCAL','BASIC',3700 UNION ALL
SELECT 'VIJAYA','1965-04-14','1992-05-02','F','FOXPRO','C',3500
These queries will import these three tables in your MySQL database
Software
Studies
Programmer
Following are the questions for which you can write the queries in MySQL workbench:-
1) Find out the SELLING COST AVERAGE for the packages developed in PASCAL?
2) Display the names and ages of all programmers.
3) Display the names and ages of all the programmers
4) What is the highest number of copies sold by a package?
5) Display the names and date of birth of all the programmers born in JANUARY.
6) Display the lowest course fee.
7) How many programmers have done the PGDCA course.
8) How much revenue has been earned through sales of packages in C.
9) Display the details of software developed by Ramesh?
10) How many programmers studied at SABHARI.
11) Display the details of PACKAGES whose sales crossed the 20000 mark.
12) Find out the number of copies which should be sold to recover the development cost of each package.
13) What is the price of the costliest software developed in BASIC?
14) Display the details of packages for which development cost has been recovered.
15) How many packages were developed in dbase?
16) How many programmers studied at paragraph?
17) How many programmers paid 5000 to 10000 for their course?
18) What is the average course fee?
19) Display the details of programmers knowing c?
20) How many programmers know either Cobol or Pascal?
21) How many programmers don't know Pascal & C?
22) How old are the oldest male programmers?
23) What is the average age of female programmers?
24) Calculate the experience in years for each programmer and display it along with the names in descending order?
25) Who are the programmers who celebrate their birthday during the current month?
26) How many female programmers are there?
27) What are the languages known by the male programmers?
28) What is the average salary?
29) How many people draw 2000 to 4000?
30) Display the details of those who don't know Clipper, Cobol, or Pascal?
31) How are many Female programmers knowing C are above 24 years of age?
32) Who are the programmers who will be celebrating their Birthday within a week?
33 Display the details of those with less than a year's experience?
34 Display the details of those who will be completing 2 years of service this year?
35 Calculate the amount to be recovered for those packages whose development cost has not been recovered?
36)ist the packages which have not been sold so far?
37) Find out the cost of the software developed by Mary?
38) Display the institute's names from the studies table without duplicates?
39) How many different courses are mentioned in the studies table?
40) Display the names of the programmers whose names contain 2 occurrences of the letter A?
41) Display the names of programmers whose names contain 5 characters?
42) How are many female programmers knowing COBOL have more than 2 years of experience?
43) What is the length of the shortest name in the programmer table?
44) What is the average development cost of a package developed in COBOL?
45) Display the name, sex, dob(DD/MM/YY format), DOJ for all the programmers without using the conversion function?
46) Who are the programmers who were born on the last day of the month?
47) What is the amount paid in salaries of the male programmers who do not know Cobol?
48) Display the title, cost, cost, and difference between cost and cost in descending order of difference?
49) Display the name, dob, DOJ of those months of birth and month of joining are same?
50) Display the names of the packages whose names contain more than 1 word?
Solutions: -
1) Find out the SELLING COST AVERAGE for the packages developed in PASCAL?
Solution:
SELECT AVG(SCOST) FROM PRACTICE.SOFTWARE where DEVELOPIN='PASCAL';
2) Display the names and ages of all programmers.
Solution: -
SELECT PNAME, TIMESTAMPDIFF (YEAR, DOB, CURDATE ()) AS AGE FROM PRACTICE.PROGRAMMER;
3) What is the highest number of copies sold by a package?
Solution: -
SELECT PNAME, MAX(SOLD) FROM SOFTWARE;
If you want a full solution or you want to learn anything then please send help request at contact@codersarts.com or fill the form or Chat with website assistance
Comments