| | | | | | English Movies
It's a Personal Blog | Sql Interview Questions - Part 1

It's a Personal Blog

just sharing what I am learning!

Sql Interview Questions - Part 1

1. What is DBMS ?

The database management system is a collection of programs that enables user to store, retrieve, update and delete information from a database.

2. What is RDBMS ?

Relational Database Management system (RDBMS) is a database management system (DBMS) that is based on the relational model. Data from relational database can be accessed or reassembled in many different ways without having to reorganize the database tables. Data from relational database can be accessed using an API , Structured Query Language (SQL).


3. What is SQL ?

Structured Query Language(SQL) is a language designed specifically for communicating with databases. SQL is an ANSI (American National Standards Institute) standard.


4. What are the different type of SQL's statements ?

This is one of the frequently asked SQL Interview Questions to freshers. SQL statements are broadly classified into three. They are:

1. DDL – Data Definition Language

DDL is used to define the structure that holds the data. For example, Create, Alter, Drop and Truncate table.

 2. DML– Data Manipulation Language

DML is used for manipulation of the data itself. Typical operations are Insert, Delete, Update and retrieving the data from the table. Select statement is considered as a limited version of DML, since it can't change data in the database. But it can perform operations on data retrieved from DBMS, before the results are returned to the calling function.

 3. DCL– Data Control Language

DCL is used to control the visibility of data like granting database access and set privileges to create tables etc. Example - Grant, Revoke access permission to the user to access data in database.


5. What are the Advantages of SQL ?

1. SQL is not a proprietary language used by specific database vendors. Almost every major DBMS supports SQL, so learning this one language will enable programmers to interact with any database like ORACLE, SQL ,MYSQL etc.

 2. SQL is easy to learn. The statements are all made up of descriptive English words, and there aren't that many of them.

 3. SQL is actually a very powerful language and by using its language elements you can perform very complex and sophisticated database operations.


6. what is a field in a database ?

A field is an area within a record reserved for a specific piece of data.

 Examples: Employee Name, Employee ID etc


7. What is a Record in a database ?

A record is the collection of values / fields of a specific entity: i.e. an Employee, Salary etc.


8. What is a Table in a database ?

A table is a collection of records of a specific type. For example, employee table, salary table etc.


9. What is a database transaction?

Database transaction takes database from one consistent state to another. At the end of the transaction the system must be in the prior state if the transaction fails or the status of the system should reflect the successful completion if the transaction goes through.


10. What are properties of a transaction?

  Properties of the transaction can be summarized as ACID Properties.

1. Atomicity

A transaction consists of many steps. When all the steps in a transaction gets completed, it will get reflected in DB or if any step fails, all the transactions are rolled back.

 2. Consistency

The database will move from one consistent state to another, if the transaction succeeds and remain in the original state, if the transaction fails.

 3. Isolation

Every transaction should operate as if it is the only transaction in the system.

 4. Durability

Once a transaction has completed successfully, the updated rows/records must be available for all other transactions on a permanent basis.


11. What is a Database Lock ?

Database lock tells a transaction, if the data item in questions is currently being used by other transactions.


12. What are the type of locks ?

1. Shared Lock

When a shared lock is applied on data item, other transactions can only read the item, but can't write into it.

 2. Exclusive Lock

When an exclusive lock is applied on data item, other transactions can't read or write into the data item.


13. What are the different  types of normalization?

In database design, we start with one single table, with all possible columns. A lot of redundant data would be present since it’s a single table. The process of removing the redundant data, by splitting up the table in a well defined fashion is called normalization.

1. First Normal Form (1NF)

A relation is said to be in first normal form if and only if all underlying domains contain atomic values only. After 1NF, we can still have redundant data.

2. Second Normal Form (2NF)

A relation is said to be in 2NF if and only if it is in 1NF and every non key attribute is fully dependent on the primary key. After 2NF, we can still have redundant data.

3. Third Normal Form (3NF)

A relation is said to be in 3NF, if and only if it is in 2NF and every non key attribute is non-transitively dependent on the primary key.


14. What is a primary key?

A primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. If a row is deleted from the table, its primary key may not be assigned to any new rows in the future. To define a field as primary key, following conditions had to be met :

1. No two rows can have the same primary key value.

2. Every row must have a primary key value

3. The primary key field cannot be null

4. Values in primary key columns can never be modified or updated


15. What is a Composite Key ?

A Composite primary key is a type of candidate key, which represents a set of columns whose values uniquely identify every row in a table.

For example -  if "Employee_ID" and "Employee Name" in a table is combined to uniquely identify a row its called a Composite Key.


16. What is a Composite Primary Key ?

A Composite primary key is a set of columns whose values uniquely identify every row in a table. What it means is that, a table which contains composite primary key will be indexed based on the columns specified in the primary key. This key will be referred in Foreign Key tables.

For example - if the combined effect of columns, "Employee_ID" and "Employee Name" in a table is required to uniquely identify a row, its called a Composite Primary Key. In this case, both the columns will be represented as primary key.


17. What is a Foreign Key ?

When a "one" table's primary key field is added to a related "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table.

For example, the salary of an employee is stored in salary table. The relation is established via foreign key column “Employee_ID_Ref” which refers “Employee_ID” field in the Employee table.

18. What is a Unique Key ?

Unique key is same as primary with the difference being the existence of null. Unique key field allows one value as NULL value.


 19. Define SQL Insert Statement ?

SQL INSERT statement is used to add rows to a table. For a full row insert, SQL Query should start with “insert into “ statement followed by table name and values command, followed by the values that need to be inserted into the table. The insert can be used in several ways:

1. To insert a single complete row.

2. To insert a single partial row.


20. Define SQL Update Statement ?

SQL Update is used to update data in a row or set of rows specified in the filter condition.

The basic format of an SQL UPDATE statement is, Update command followed by table to be updated and SET command followed by column names and their new values followed by filter condition that determines which rows should be updated.


21. Define SQL Delete Statement ?

SQL Delete is used to delete a row or set of rows specified in the filter condition.

The basic format of an SQL DELETE statement is, DELETE FROM command followed by table name followed by filter condition that determines which rows should be updated.


22. What are wild cards used in database for Pattern Matching ?

 SQL Like operator is used for pattern matching. SQL 'Like' command takes more time to process. So before using "like" operator, consider suggestions given below on when and where to use wild card search.

 1) Don't overuse wild cards. If another search operator will do, use it instead.

2) When you do use wild cards, try not to use them at the beginning of the search pattern, unless absolutely necessary. Search patterns that begin with wild cards are the slowest to process.

3) Pay careful attention to the placement of the wild card symbols. If they are misplaced, you might not return the data you intended.


Comments (15) -

  • ab

    8/9/2016 7:29:32 PM | Reply

    good list of sql interview questions! thanks

  • Soledad Devora

    9/5/2017 2:08:31 PM | Reply

    Only  wanna  input on few general things, The website  layout is perfect, the  written content  is  real   superb  : D.

  • Marnie Eckert

    9/6/2017 1:31:21 PM | Reply

    Thanks for all of the efforts on this site. Debby enjoys carrying out investigations and it's obvious why. Most of us know all regarding the powerful tactic you convey both useful and interesting strategies on the web blog and in addition boost response from website visitors on this theme and our girl is truly learning a lot of things. Enjoy the rest of the new year. You're the one performing a remarkable job.

  • Jeff Mccool

    9/6/2017 3:26:53 PM | Reply

    Some really   fantastic   information,  Gladiola  I found  this. "We protest against unjust criticism, but we accept unearned applause." by Jose Narosky.

  • Treasa Bartholomew

    9/6/2017 3:26:54 PM | Reply

    you are truly a excellent webmaster. The site loading pace is incredible. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a magnificent activity in this topic!

  • Franklyn Modic

    9/6/2017 3:26:54 PM | Reply

    I really appreciate this post. I've been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thanks again!

  • Arturo Bayona

    9/6/2017 3:41:49 PM | Reply

    I just could not depart your site prior to suggesting that I actually loved the standard information a person provide on your visitors? Is going to be again regularly to inspect new posts.

  • Lesley Madril

    9/6/2017 3:41:49 PM | Reply

    But a smiling visitant here to share the love (:, btw great style. "Better by far you should forget and smile than that you should remember and be sad." by Christina Georgina Rossetti.

  • Brooks Barnhouse

    9/6/2017 3:41:54 PM | Reply

    I dugg some of you post as I  cogitated  they were  handy   very helpful

  • Luis Sammer

    9/6/2017 4:07:50 PM | Reply

    Nice blog here! Also your web site loads up fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

  • Alayna Bridendolph

    9/6/2017 4:07:51 PM | Reply

    Really   superb  info  can be found on blog . "There used to be a real me, but I had it surgically removed." by Peter Sellers.

  • Morgan Brookshaw

    9/6/2017 4:07:53 PM | Reply

    Very interesting info !Perfect just what I was  searching  for! "To be without some of the things you want is an indispensable part of happiness." by Bertrand Russell.

  • Keren Louissaint

    9/12/2017 12:24:01 PM | Reply

    I've been absent for some time, but now I remember why I used to love this blog. Thank you, I'll try and check back more frequently. How frequently you update your site?

  • Elenor Crunkilton

    9/12/2017 4:33:33 PM | Reply

    My brother recommended I might like this website. He was totally right. This post actually made my day. You cann't imagine just how much time I had spent for this info! Thanks!

  • Jimmie Sick

    9/12/2017 5:07:14 PM | Reply

    Thanks for all your valuable effort on this web page. Betty enjoys going through research and it's obvious why. All of us know all of the dynamic form you create sensible things via the website and as well inspire participation from some other people about this subject matter so our own child is without question discovering a whole lot. Take pleasure in the remaining portion of the new year. You are always doing a fantastic job.