0% found this document useful (0 votes)
4 views6 pages

Viva Cs

The document provides a comprehensive overview of MySQL concepts, including definitions of DDL, DML, RDBMS, and data inconsistency. It explains key database terms such as primary key, candidate key, selection, projection, and various SQL commands and functions. Additionally, it covers differences between database elements and operations, such as the use of WHERE vs. HAVING, and the role of foreign keys in relational databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Viva Cs

The document provides a comprehensive overview of MySQL concepts, including definitions of DDL, DML, RDBMS, and data inconsistency. It explains key database terms such as primary key, candidate key, selection, projection, and various SQL commands and functions. Additionally, it covers differences between database elements and operations, such as the use of WHERE vs. HAVING, and the role of foreign keys in relational databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

MySQL|VineetaGarg

MY SQL
VIVAQUESTIONS

1. WhatisDDLandDML?
DDL(DataDefinitionLanguage):Allthecommandswhichareusedtocre
ate, destroy, or restructure databases and tables come under this
category. Examples of DDL commands are - CREATE, DROP, ALTER.
DML (Data Manipulation Language): All the commands which are
used to manipulate data within tables come under this category.
Examples of DML commands are - INSERT, UPDATE, DELETE.

2. WhatisRDBMS?
RDBMS: A DBMS used to manage Relational Databases is called an
RDBMS (Relational Data Base Management System). Some popular
RDBMS software available are: Oracle, MySQL, Sybase, Ingress.

3. Whatisdata inconsistency?
Datainconsistencyoccurswhensamedatapresentintwodifferenttablesdo
esnot match.

4. Whatisarelation?
Relation/Table: A table refers to a two-dimensional representation of
data
arrangedincolumns(alsocalledfieldsorattributes)androws(alsocalledrec
ords or tuples).

5. Whatiscardinalityanddegree?
Cardinality:Totalnumberofrowsinatableiscalledthecardinalityofthetab
le. Arity/Degree: Total number of columns of a table is called the
Degree of the table.

6. What is the difference between primary key, candidate key and


alternate key?
Primary Key: The group of one or more columns used to
uniquelyidentify each row of a relation is called its Primary Key.
Candidate Key: A column or a group of columns which can be used
as the
primarykeyofarelationiscalledacandidatekeybecauseitisoneofthecandi
dates available to be the primary key of the relation.
Alternate Key: A candidate key of a table which is not made its
primary key is called its Alternate Key.

7. Whatisselectionandprojection?

1
MySQL|VineetaGarg

The SELECTION operation is a horizontal subset of table/relation and is


used to choose the tuples(rows) from a relation that satisfies a given
condition. It is denoted by the symbol σ (sigma).
The PROJECTION operation is a horizontal subset of table/relation and
used to choose the attributes(columns) from a relation that are given
in the attribute list. It is denoted by the symbol ∏ (pi).

8. Whatarethedifferenttypesofclausesusedin wherecommand?
CLAUSE/KEYWORD USAGE

DISTINCT Usedtodisplaydistinctvalues(removes
duplicatevalues)fromacolumnofatable.

WHERE Usedtospecifytheconditionbasedon
which rows of a table are displayed.

BETWEEN Used to define the range of values within


which the column values must fall to
make a
conditiontrue.Rangeincludesboththeup
per and the lower values.
IN Usedtoselectvaluesthatmatchanyvaluein
a
listofspecifiedvalues.
LIKE Usedforpatternmatchingofstringdata
using wildcard characters % and _.

% (percentage): It is used to represent


any sequence of zero or more
characters.
_(underscore):Itisusedtorepresenta
single character.
IS NULL Usedtoselectrowsinwhichthespecified
column is NULL (or is NOT NULL).

ORDERBY Usedtodisplaytheselectedrowsinascending
or in descending order of the specified
column/expression.

GROUPBY Group by clause is used when we need to


group the data of the table based on
certain type.

2
MySQL|VineetaGarg

9. Whatisacartesian product?
Cartesianproductoftwotablesisatableobtainedbypairingeachrowofonet
able with each row of another table. The table obtained has
columns=sumofthecolumnsofboththetables
rows=productoftherowsofboththetables It
is represented by the symbol X.
10. WhatisaUNION?
Union of two tables is a table in which the number of columns is same
as the
numberofcolumnsofthetwotablesandnumberofrowsisthesumofthenum
ber of rows of both the tables.
Unionoperationcanbeappliedontwotablesonlyifthetableshavesamenum
ber and type of columns.

11. Giveacommandtoinsertanewcolumnintoatable?Altertable

12. Giveacommandtodeletea columnfromatable?Altertable

13. Giveacommandtodeletearowfromatable?Deletefrom

14. Giveacommandtoinsertanewrowintoatable?Insertinto

15. Whatisadifferencebetweendatabaseand table?


Databaseisacollectionofrelatedtables
Tableisa collectionofrelateddataintheformofrowsandcolumns

16. Whatisthedifferencebetweenupdate andaltercommand?


ALTERcommandisaDataDefinitionLanguageCommand.UPDATEcomma
ndis a Data Manipulation Language Command.
ALTERCommandadd,delete,modifytheattributesoftherelations(tables)inth
e database. UPDATE Command modifies one or more records in the
relations.

17. Whathappenswhenthedroptablecommandis
executed?
Alltherecordsaswellastheentirestructureofthetableisdeleted.

18. InSQLcanMAXfunctionbeappliedtodateand chartype date?


Yes

19. Whatareaggregatefunctions?
Aggregatefunctionsworkonmultiplerows.Thereare5typesofaggregate
functions:

Aggregatefunction Purpose

3
MySQL|VineetaGarg

MAX() Tofindthemaximumvalueunder
the specified column

4
MySQL|VineetaGarg

MIN() Tofindtheminimumvalueunder
the specified column
AVG() To find the average of values
under the specified column
SUM() To find the sum of values under
the specified column
COUNT() Tocountthevaluesunderthespeci
fied column

20. Differencebetweencount()and count(*)

When the argument is a column name or an expression based on a


column, COUNT() returns the number of non-NULL values in that
column.
If the argument is a *, then COUNT() counts the total number of rows
satisfying the condition, if any, in the table.
21. Whatisthepurposeofgroup byclause?
GroupbyclauseisusedtogetherwiththeSQLSELECTstatementtogroupth
edata
ofthetablebasedoncertaintype.Itarrangesidenticaldataintogroups.Itret
urns only one single row for every grouped item.

22. Whatisthedifferencebetweenwhere&having?

WHERE is used to put a condition on individual row of a table


whereas HAVING is used to put condition on individual group formed
by GROUP BY clause in a SELECT statement.

23. Whatisequi join?


When we extract data from two tables, they must have one column
which is
presentinboththetables.Anequijoinoftwotablesisobtainedbyputtingan
equality condition on the Cartesian product of two tables.
Thisequalityconditionisputonthecommoncolumnofthetablesandiscalled
equi join condition.
24. Whatisaforeignkey?
Foreignkeyisacolumninonetablewhich istheprimarykeyof anothertable.
Foreg.ThecolumnDeptnoistheprimarykeyofdepttableandtheforeignkeyo
f emp table.

It is important that no entry should be made in the emp table in which

5
MySQL|VineetaGarg

deptno
doesnotbelongtodepttableiewecannotwritedeptnoinemptablewhichdoe
s not exist in dept table.

You might also like