Java J2ee Struts Hibernate Spring Interview Questions Java J2ee Struts Hibernate Spring Interview Questions
13 Results; Time:0.03 Sec; Page : 1 ; Results From 1 to 10. Results Per Page

1. Consider 2 tables 8th standard students and 9th standard students. Can you write a query to find the students having the same name in both classes ?

Select from 8,9 where ==

2. Can you write a query to find the students having the name in only 8 but not in 9 th.

Select from 8 MINUS Select from 9;
Select from 8 where not in (select from 9).
IN is most expensive in terms of performance, you can use having clause or something else...

3. What are the differences between Primary Key and Foreign Key ?

The primary key consists of one or more columns whose data contained within is used to uniquely identify each row in the table. 

ex- Aadhaar Number, Social Security Number, Passport Numbers can be set as Primary to uniquely identify persons in Peoples table.

A foreign key is a set of one or more columns in a table that refers to the primary key in another table.

ex-this person belongs to a department - department id is a primary key in department table.

In Peoples table you can put foreign key department id which points to department id [The primary key ] of
department table.

4. Can you explain about database normalization ?

Database normalization is a process used to organize a database into tables and columns.
The idea is that a table should be about a specific topic and that and only supporting topics included.
By limiting a table to one purpose you reduce the number of duplicate data contained within your database.
This eliminates some issues stemming from database modifications.

Why you will not put all the data in a single table ?
Splitting up of all data into several tables and later fetch data by sql queries.

There are three main reasons to normalize a database. 
The first is to minimize duplicate data,
the second is to minimize or avoid data modification issues,
and the third is to simplify queries.
There are three common forms of database normalization: 1st, 2nd, and 3rd normal form.
They are also abbreviated as 1NF, 2NF, and 3NF respectively.
There are several additional forms, such as BCNF,
Boyce-Codd normal form (or BCNF or 3.5NF) is a normal form used in database normalization.
It is a slightly stronger version of the third normal form (3NF).
BCNF was developed in 1974 by Raymond F Boyce and Edgar F Codd to address certain types of anomalies not dealt with by 3NF as originally defined.

5. If you create an index on tables, search will be faster, but how, Can you explain ?

If you create an index on tables, search will be faster as they internally use BST - binary search tree

traversing through a large table of comments section of a blog to find those for the relevant post would be expensive

Because you possibly believe that a linear search will be done every time taking O(n) time. For a billion comments, a billion iterations will be done.

Now suppose a binary search tree is constructed for comment_ID on comments table.
To look up any comment, you need log(n) time [base 2].
So for even 1 billion comments, only around 32 iterations will be needed.

2 ^ 32 = 2^10 * 2^10 * 2^10 * 2^2
1 billion = 2^9 1024*1024*1024

Now consider a slightly modified BST, where each node contains k elements instead of 1 (in a list) and has k+1 children nodes.

The same properties of BST are followed in this data structure as well. What we've got here is called a B-tree.

For a B-Tree, the lookup time is log(n) [base k]. Hence, if k=10, for 1 billion entries, only 9 iterations will be needed.

All databases save indexes for primary keys in B-Trees. Hence, the stated task would not be expensive, and you should go ahead and design the database the way it seemed obvious.

PS: You can build an index on any column of the table. By default primary key indexes are already stored. But be careful, do not make unnecessary indexes as they take up disk space.

 More reading : B Tree

6. Can you explain the difference between dbms and rdbms ?

Please Answer

7. What does that r stands for in RDBMS or Why we call it relational dbms ?

RDBMS. Stands for "Relational Database Management System."
An RDBMS is a DBMS designed specifically for relational databases. Therefore, RDBMSes are a subset of DBMSes.
A relational database refers to a database that stores data in a structured format, using rows and columns.

There is a relationship between data in each row and relationships between tables.

Apart from RDBMS, there are object databases also there.

8. Can you explain about Cursor ?

A cursor is a pointer used to fetch rows from a result set. One can think of a cursor as a data structure that describes the results returned from a SQL SELECT statement. One of the variables in this structure is a pointer to the next record to be fetched from the query results.

Note that if you do repetitive stuff inside a loop and you fail to close your cursors, you would soon run into the ORA-01000: maximum number of open cursors exceeded error.

9. Explain various types of joins SQL ?

equi join, non equi join, cross join, self join, inner join or simple join, left outer join, right outer join, full outer join

10. What is a Union in SQL. Give a real-time example ?

Set operations allow the results of multiple queries to be combined into a single result set.
Set operators include UNION, INTERSECT, and EXCEPT.
The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
It removes duplicate rows between the various SELECT statements.
Each SELECT statement within the UNION must have the same number of fields or columns in the result sets with similar data types.

Java J2ee Struts Hibernate Spring Interview Questions
13 Results; Time:0.03 Sec; Page : 1 ; Results From 1 to 10. Results Per Page
Menu - - Java J2ee Struts Spring Hibernate Interview Questions - A home for your website
Ads By Google