Skip to main content

ads1

MySQL SQL Revision Tour

 MySQL SQL Revision Tour 



SUMMARY

The basic elements of MySQL SQL are: literals, datatypes, nulls and comments.

Literals are fixed data values.

Data types of MySQL SQL include: NUMERIC (INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT, FLOAT(M, D), DOUBLE(M. D) AND DECIMAL(M, D), DATE and TIME (DATE, DATETIME, TIMESTAMP, TIME and YEAR(M) and STRING (CHAR(M). VARCHAR(M), BLOB or TEXT, TINYBLOB or TINYTEXT, MEDIUMBLOB or MEDIUMTEXT and ENUM). 

Column having no value is said to have NULL value.

The SELECT command of SQL lets you make queries on the database. 

The DISTINCT keyword eliminates redundant data.

To perform calculations, the expressions can be written along with SELECT without specifying any table name.

A small work table Dummy can be used for making simple calculations.

The curdate pseudo-column returns the current system date.

The WHERE clause is used to select specific rows.

The logical operators OR (II), AND (&&) and NOT (!) are used to connect search conditions in the WHERE clause.

The BETWEEN operator is used for making range checks in queries. The IN operator is used for selecting values from a list of values.

The LIKE operator is used for making character comparisons using strings.

The null value in a column can be searched for in a table using IS NULL in the WHERE clouse

CREATE TABLE command is used to create tables in database.

INSERT INTO command is used to insert data in the table.

To insert data from other tables, subquery can be used inside INSERT INTO command. 

Existing data in tables can be changed with UPDATE command.

Tuples in a table can be deleted using DELETE command. ALTER TABLE command is used to alter the definition of already created tables.

With ALTER TABLE, new columns can be added, existing columns can be redefined.

DROP TABLE command drops a table from a database.

Link to Download Chapter - 5 






Answer the Following Question :- 

TOPIC – DBMS CONCEPTS

Q1. What is a database?

Ans. A database is a collection of interrelated data

Q2 What is data redundancy?

Ans. Data Redundancy means duplication of data in a database.

Q3 What is metadata ?

Ans. Data about data

Q4 What do you mean by degree and cardinality of a table?

Ans. Degree:- No. of columns with in a table.

Cardinality:- No. of rows within a table.

Q5 What is tuple?

Ans. Rows in a table are called tuple

Q6 What is domain?

Ans. Domain is the pool of values from which actual values appearing in a column aretaken.

Q7 What is the full form of DBMS?

Ans. Database Management System

Q8 Full form of DDL.

Ans. Data Definition Language

Q9 Full form of DML.

Ans. Data Manipulation Language

Q10 How many primary key can be present in a table ?

Ans. one

Q11 What is the full form of SQL?

Ans Structured Query Language


TOPIC - SQL BASICS ( DDL AND DML COMMANDS)

PART A , Section I

1 Which of the following is a DDL command?

a) SELECT b) ALTER c) INSERT d) UPDATE

Ans. b) ALTER

2 What is the minimum number of column required in MySQL to create table?

Ans. ONE (1)

3 The ____________command can be used to makes changes in the rows of a table in SQL.

Ans.

4 Which command is used to add new column in existing table?

Ans. ALTER TABLE

5 Which command is used to remove the table from database?

Ans. DROP TABLE

6 Which command is used to add new record in table?

Ans. INSERT INTO

7 In SQL, name the clause that is used to display the tuples in ascending order of an

attribute

Ans. ORDER BY

8 In SQL, what is the use of IS NULL operator?

Ans. IS NULL used to compare NULL values present in any column

9 Which of the following types of table constraints will prevent the entry of duplicate

rows? a)Unique b)Distinct c)Primary Key d)NULL

Ans. c) Primary Key

10 Which is the subset of SQL commands used to manipulate database structures, including

tables?

a.None of these

b.Both Data Definition Language (DDL) and Data Manipulation Language (DML)

c.Data Definition Language (DDL)

d.Data Manipulation Language (DML)

Ans. c.Data Definition Language (DDL)




ads2

Popular posts from this blog

11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following:

    11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following: Basic Salary <= 10000 : HRA = 20%, DA = 80% Basic Salary <= 20000 : HRA = 25%, DA = 90% Basic Salary > 20000 : HRA = 30%, DA = 95% Static Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     if(basic <=10000)     {         da = basic * 0.8;         hra = basic *0.2;     }              else if(basic <=20000)     {         da = basic * 0.9;         hra = basic *0.25;     }     else     {         da = basic * 0.95;         hra = basic * 0.3;     }     gross = basic + da + hra;     System.out.println("The Gross Salary is :-"+gross);     } } Output :-  Dynamic Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     Scanner in = new Scanner(System.in);     System.out.println("Enter the Basic Salary

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise or class wise.

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise  or class wise. Solution :-   # x-axis is shows the subject and y -axis # shows the markers in each subject # import pandas and matplotlib  import pandas as pd  import matplotlib.pyplot as plt # Simple Line Chart with setting of Label of X and Y axis, # title for chart line and color of line  subject = ['Physic','Chemistry','Mathematics', 'Biology','Computer'] marks =[80,75,70,78,82] # To draw line in red colour plt.plot(subject,marks,'r',marker ='*')     # To Write Title of the Line Chart plt.title('Marks Scored') # To Put Label At Y Axis plt.xlabel('SUBJECT')           # To Put Label At X Axis plt.ylabel('MARKS')             plt.show() Output :- 

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category. import pandas as pd  # initialize list of lists data = [['CAR','Maruti',1000000],['AC','Hitachi',55000],['AIRCOLLER','Bajaj',12000], ['WASHING MACHINE','LG',15000],['CAR','Ford',7000000],['AC','SAMSUNG',45000],['AIRCOLLER','Symphony',20000],['WASHING MACHINE','Wirlpool',25000]] Col=['itemcat','itemname','expenditure'] # Create the pandas DataFrame qrtsales = pd.DataFrame(data,columns=Col) # print dataframe.  print (qrtsales) qs=qrtsales.groupby('itemcat')  print('Result after Filtering Dataframe')  print(qs['itemcat','expenditure'].sum()) Output :-