sql ques ans(part P)

76.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.

77.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.

78. 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.

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

80. 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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s