0% found this document useful (0 votes)
2 views

MySQL InterviewDoc copy

The document provides an overview of databases, focusing on concepts such as DBMS, RDBMS, SQL, and various types of keys and constraints. It explains the differences between data types, joins, and SQL commands, as well as the roles of DDL and DML in database management. Additionally, it covers practical SQL queries for retrieving specific data from tables.

Uploaded by

emir deniz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MySQL InterviewDoc copy

The document provides an overview of databases, focusing on concepts such as DBMS, RDBMS, SQL, and various types of keys and constraints. It explains the differences between data types, joins, and SQL commands, as well as the roles of DDL and DML in database management. Additionally, it covers practical SQL queries for retrieving specific data from tables.

Uploaded by

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

1

By BobIT

MySQL

1- What is database?

A database is an organized collection of data, stored and retrieved digitally from a


remote or local computer system. Databases can be vast and complex, and such
databases are developed using fixed design and modeling approaches.

2- What is DBMS”

DBMS stands for Database Management System. DBMS is a system software responsible
for the creation, retrieval, updating and management of the database. It ensures that
our data is consistent, organized and is easily accessible by serving as an interface
between the database and its end users or application software.

3- What is RDBMS? Differences DBMS?

RDBMS stands for Relational Database Management System. The key difference here,
compared to DBMS, is that RDBMS stores data in the form of a collection of tables and
relations can be defined between the common fields of these tables. Most modern
database management systems like MySQL, Microsoft SQL Server, Oracle, IBM DB2 and
Amazon Redshift are based on RDBMS.

4- What is SQL?

SQL stands for Structured Query Language. It is the standard language for relational
database management systems. It is especially useful in handling organized data
comprised of entities (variables) and relations between different entities of the data.

5- SQL and MySQL

SQL is a standard language for retrieving and manipulating structured databases. On the
contrary, MySQL is a relational database management system, like SQL Server, Oracle or
IBM DB2, that is used to manage SQL databases.

6- What are the constraints in SQL?

Constraints are used to specify the rules concerning data in the table. It can be applied
for single or multiple fields in an SQL table during creation of table or after creationg
using the ALTER TABLE command. The constraints are:

MySQL www.ilhanturkmen.net www.siliconelabs.com


2

By BobIT

NOT NULL - Restricts NULL value from being inserted into a column.
CHECK - Verifies that all values in a field satisfy a condition.
DEFAULT - Automatically assigns a default value if no value has been specified for the
field.
UNIQUE - Ensures unique values to be inserted into the field.
INDEX - Indexes a field providing faster retrieval of records.
PRIMARY KEY - Uniquely identifies each record in a table.
FOREIGN KEY - Ensures referential integrity for a record in another table.

7- What is primary key?

A primary key is a combination of fields which uniquely specify a row. This is a special
kind of unique key, and it has implicit NOT NULL constraint. It means, Primary key values
cannot be NULL.

8- What is unique key?

A Unique key constraint uniquely identified each record in the database. This provides
uniqueness for the column or set of columns.

A Primary key constraint has automatic unique constraint defined on it. But not, in the
case of Unique Key.

There can be many unique constraints defined per table, but only one Primary key
constraint defined per table.

9- What is foreign key?

A foreign key is one table which can be related to the primary key of another table.
Relationship needs to be created between two tables by referencing foreign key with
the primary key of another table.

10- What are the types of join and explain each?

MySQL www.ilhanturkmen.net www.siliconelabs.com


3

By BobIT

There are various types of join which can be used to retrieve data and it depends on the
relationship between tables.

Inner Join.
Inner join return rows when there is at least one match of rows between the tables.

Right Join.
Right join return rows which are common between the tables and all rows of Right-hand
side table. Simply, it returns all the rows from the right-hand side table even though
there are no matches in the left-hand side table.

Left Join.
Left join return rows which are common between the tables and all rows of Left-hand
side table. Simply, it returns all the rows from Left hand side table even though there
are no matches in the Right-hand side table.

Full Join.
Full join return rows when there are matching rows in any one of the tables. This means,
it returns all the rows from the left-hand side table and all the rows from the right-hand
side table.

11- What is the constraint?

Constraint can be used to specify the limit on the data type of table. Constraint can be
specified while creating or altering the table statement. Sample of constraint are.

NOT NULL.
CHECK.
DEFAULT.
UNIQUE.
PRIMARY KEY.
FOREIGN KEY.

12- What is self-join?

Self-join is set to be query used to compare to itself. This is used to compare values in a
column with other values in the same column in the same table. ALIAS ES can be used
for the same table comparison.

13- What is cross-join?

MySQL www.ilhanturkmen.net www.siliconelabs.com


4

By BobIT

Cross join defines as Cartesian product where number of rows in the first table
multiplied by number of rows in the second table. If suppose, WHERE clause is used in
cross join then the query will work like an INNER JOIN.

14- What is Clause?

SQL clause is defined to limit the result set by providing condition to the query. This
usually filters some rows from the whole set of records.

Example – Query that has WHERE condition

Query that has HAVING condition.

15- What is Union, minus, interact commands?

UNION operator is used to combine the results of two tables, and it eliminates duplicate
rows from the tables.

MINUS operator is used to return rows from the first query but not from the second
query. Matching records of first and second query and other rows from the first query
will be displayed as a result set.

INTERSECT operator is used to return rows returned by both the queries.

16- What is difference between truncate and drop statements?

TRUNCATE removes all the rows from the table, and it cannot be rolled back. DROP
command removes a table from the database and operation cannot be rolled back.

17- How to select unique value from the table?

Select unique records from a table by using DISTINCT keyword.

18- What is difference between varchar and char?

Both of these datatypes are used for characters but varchar2 is used for character
strings of variable length whereas char is used for character strings of fixed length. For
example, if we specify the type as char(5) then we will not be allowed to store string of
any other length in this variable but if we specify the type of this variable as varchar2(5)
then we will be allowed to store strings of variable length, we can store a string of
length 3 or 4 or 2 in this variable.

MySQL www.ilhanturkmen.net www.siliconelabs.com


5

By BobIT

19- What is DDL?

Data definition language or DDL allows to execute queries like CREATE, DROP and
ALTER. That is, those queries which define the data.

20- What is the DML?

Data manipulation Language or DML is used to access or manipulate data in the


database.
It allows us to perform below listed functions:
Insert data or rows in database
Delete data from database
Retrieve or fetch data
Update data in database.

21- Unique and primary key

Primary key cannot have NULL value, the unique constraints can have NULL values.
There is only one primary key in a table, but there can be multiple unique constrains.
The primary key creates the cluster index automatically, but the Unique key does not

22- What is foreign key?

A Foreign key is a field which can uniquely identify each row in another table. And this
constraint is used to specify a field as Foreign key. That is, this field points to primary key
of another table. This usually creates a kind of link between the two tables.

23- How to find highest salary?

24- How to find lowest salary?

MySQL www.ilhanturkmen.net www.siliconelabs.com


6

By BobIT

25- How to find second highest salary:

26- Which salaries are above the average?

27- Which salaries are below the average?

28- How to learn a name how many times there are in table?

MySQL www.ilhanturkmen.net www.siliconelabs.com


7

By BobIT

MySQL www.ilhanturkmen.net www.siliconelabs.com

You might also like