Database Interview Questions And Answers |
49.
What are E-R diagrams?
E-R diagrams, i.e. Entity-Relationship diagram represent relationship between various tables in the database.
|
50.Explain the types of relationships in database
One-to-one
One to one is implemented using single table by establishing relationship between same type of columns in a table.
One-to-many
Implemented using two tables with primary key and foreign key relationships.
Many-to-many
Implemented using a junction table.
The keys from both the tables form composite primary key of the junction table. |
51.
What is Union and Union All operator?
Union is used to combine distinct records from two tables.
Union all combines all records from two tables.
|
52.What is cursor?
A Cursor is a database object that represents a result set and is used to manipulate data row by row. When a cursor is opened, it is positioned on a row and that row is available for processing. |
53.
Explain the cursor types.
DYNAMIC: It reflects changes happened on the table while scrolling through the row.
STATIC: It works on snapshot of record set and disconnects from the server. This kind doesn’t reflects changes happened on the table while scrolling through the row.
KEYSET: In this kind, new record is not reflected, but data modification can be seen. |
54. Explain in brief the cursor optimization tips.
Close cursor when it is not required.
You shouldn’t forget to deallocate cursor after closing it.
You should fetch least number of records.
You should use FORWARD ONLY option when there is no need to update rows. |