DATABASE Programming Questions & Answers

Explore model answers categorized by subjects like Java, HTML, DBMS, and more.

DATABASE Programming Questions & Answers

Explain the difference between a database administrator and a data administrator.

Answer:
Database Administrator: A Person who is responsible for maintening Database and review conntent of Database.Planning, configuration and relating to them other systems for that organization.
Data Administrator: The Data Adminitrator is person who is resposible for:
1. Specification of Organization data
2. Acquisition of Data 
3. Maintenance of data management software and the design.
4. Validation of files and data
5. Security of files or databases.  

What is a Database Transactions ?

Answer:
Database transaction is a unit of work in database managment system.Database transaction must follow term ACID(Atomocity, Consistency, Isolation, Durability)..Any transaction started then till it complition,that transaction follow ACID,for successful and no error. 

What is ACID?

Answer:
ACID means atomicity, consistency, isolation and durability.

1. Atomicity:Each transaction is said to be “atomic".Means if any part of transaction fail then whole transaction failed.In a word say "ALL OR NOTHING".The failure of transaction commanaly depend on Hard disk fail,System crash.

2. Consistency:Consistency means only valid data will be written to the database.If any transaction voilate any consistency rule of database the whole transaction is Rollback, means it starts again from beggining.Each state in transaction must be consistent for database.

3. Isolation: If two transactions occures at a time then both are not impact to each other,seperate complition of each transaction. The isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.If second transaction depend on frist then it will done, and data update after complition of traction.

Durability:Ensures that any transaction committed to the database will not be lost. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.

What is Concurrency?

Answer:
If two transaction occure same time. The system ensure a control,due to that one transaction do not adversely affect the other. This is called concurrency control.

1. Pessimistic concurrency control: System locks prevents users from modifying data in a way that affects other users. After a user performs an action that causes a lock to be applied, other users cannot perform actions that would conflict with the lock until the owner releases it. 

2. Optimistic concurrency control: This is called optimistic because it is mainly used in environments where there is low contention for data, and where the cost of occasionally rolling back a transaction outweighs the costs of locking data when read.

What is a Deadlock?

Answer:
Any database system perform many trasaction,a trasaction run and it uses other utility of system.Another transaction needed this utility, then it goes to waiting state. This problem occure among many trasaction is called Deadlock. 

Define rollback and roll forward ?

Answer:
Rollback: Undoing the changes made by a transaction in terms:
1. Before transaction  commits. 
2. To cancel any changes to a database during current transaction.
3. Transaction not be consistent.

RollForward: Re-doing the changes made by a transaction in terms
1. After it commits 
2. To overwrite the changed value again to ensure consistency.

what is database?

Answer:
Database is an important constituent for collection and storage of data.Data provided information after processing on them.To managing record and importent data Databases server used.

Explain about object oriented databases?

Answer:
Object oriented databases are used to store:
1. Much more complex data.
2. Designed to store information related to multimedia.
3. Engineering databases.
4. Spatial Databases. 
5. Databases even stored data about software’s repositories. 
This  type database was adopted in late ninety`s and new features were added.

Explain about XML databases?

Answer:
XML databases came into existence in 2000. This database lets you organize data irrespective of whether it is organized or not.This data can exported and serialized into the desired format. 
Two major classes of XML database exist:
1. XML-enabled
2. Native XML

Explain about the hierarchical model of database?

Answer:
The word hierarchi means tree form relationship,like a tree  with branches.Means Relationship formed like tree structure in a database called  hierarchical model.With this database you form relationship among many tables with certain concept.It has a downward link to describe the nesting and they are arranged in a particular order down the same level of the list. 

Explain about Network model?

Answer:
This model provides greater flexibility and easy access to data.This model provide logical relationship among many parent database.But implimenting this model is more difficult due to time consuming and cost. Its flexible because through link easily accesesing of information.

Explain about relational database?

Answer:
Relational Database:
1. Data represent in form of coloumn and row, coloumn means attribute and row means touples present instance of data.
2. This Database model came into existence with help of mathematical concepts.
3. Using some other concepts like normalization, touple relational calculus.

Disadvantage of File Processing System or Advantage of Database over File Processing System ?

Answer:
1. Data redundancy and consistency:Not easily in File System but in database possible.
2. Difficalty to accessing data:In database easily done.
3. Data isolation:Database provided but in File System not.
4. Data integrity:Database provided but in File System not.
5. Concurrent access is not possible:Database provided but in File System not.
6. Security Problems:Database provided but in File System not.

Describe levels of Abstraction in Database?

Answer:
1. Physical Level:Physical level is the lower level of abstraction.Its define how data is stored in database.
2. Logical Level:The next higher level of abstraction, its describe what data be store and each logical operation done at this level, links and concept apply here.
3. View Level:This is the higher level describe only part of entire  database.

What is extension and intension?

Answer:
Extension: It is the number of tuples(row) present in a table at any instance. This is time dependent.

Intension:
It is a constant value that gives the:
1. Name
2. Structure of table
3. The constraints laid on it. 

What is Data Independence in Database System?

Answer:
Data independence means that, the ability to modify the schema definition in one level should not affect the schema definition in the next higher level. The application is independent of the storage structure and access strategy of data.
Two types of Data Independence are:

1. Logical Data Independence: It is more difficult to achieve. Modification in logical level should affect the view level. 
2. Physical Data Independence: Modification in physical level should not affect the logical level.

What is a view in database system and how it is related to data independence?

Answer:
View is a table that does not really exist in its own right, it derived from one or more underlying base table. In other word view is a virtual table. There is no stored file that direct represents view.
Following terms:
- Views can represent a subset of the data contained in a table.
- View perform alogical operations.
- View can join multiple table in a single vertual table.
- Importent feature is, to hide complexity of data.

Now disscuss how view relate data independence,  restructuring of base tables is not reflected in views. Thus the view can insulate users from the effects of restructuring and growth in the database. Hence accounts for logical data independence.

What is E-R Model in Database system?

Answer:
E-R model stands for Entity-Relationship model. This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entity in database, which existence in real world with number of attributes. In a table attribute know as column. Relationship is a logical thing which relates entities. The E-R diagram shows structure of E-R model.

What is Object Oriented model in Database system?

Answer:
This model is based on collection of objects. An object is instance variables which store value and bodies of code, that codes are called method. These codes have written to operate the objects.  Objects that contain same types of values and the same methods are grouped together into classes. In other words classes are a group of object. This model also follows the some concept related to the OOPs

What is Weak Entity and Weak Entity set?

Answer:
Entity is dependent on another entity called weak entity. An entity set may not have sufficient attributes to form a primary key is a Weak Entity set. 

What is an attribute?

Answer:
Attribute is a property which describe entity. In Database table it’s known as Column

What are a Relation Schema and a Relation in Database System?

Answer:
A relation Schema is made up of the relation and the list of attributes. It is denoted by R(C1, C2, ?, Cn), where R is the relation name and C1…Cn  is the number of attribute.
A relation is a set of tuples. Let r be the relation which contain attribute list p1,p2..pn. Each touple is a ordered list of values p=(t1,t1…..tn).

What is Degree and Cardinality of a Relation in Database System?

Answer:
Degree of a relation is the number of attribute of its relation schema and Cardinality of a relation is the number of tuples.

What is DDL)?

Answer:
A set of definitions specified data base schema is called DDL (Data Definition Language).

What is DML (Data Manipulation Language) in Database system?

Answer:
This language that enable user to access and manipulate data. Data are organized by appropriate data model.
Two types DML:
1. Procedural DML or Low level: DML requires a user to specify what data are needed and how to get those data. 
2. Non-Procedural DML or High level: DML requires a user to specify what data are needed without specifying how to get those data. 

What is DML Compiler?

Answer:
DML Compiler translates DML statements in a query language or we say into low-level instruction. That instruction is understandable by Query evaluation engine.

What is Query evaluation engine?

Answer:
Query evaluation engine execute low level instruction generate by DML Compiler

What is Relational Algebra in database System?

Answer:
Relational algebra is procedural query language in database. It consists of a set of instructions that operate one or two relations and produce a new relation. These set of instruction is known as Relation Algebra operations

What is Relational Calculus?

Answer:
It is a set of rules to manipulate table through constrains. It is an applied predicate calculus specifically tailored for relational databases proposed by E.F. Codd. E.g. of languages based on it are DSL ALPHA, QUEL.

What is Normalization in database?

Answer:
To remove the redundancy of a table as called Normalization. In other words duplicity or repetitions of data never occur in database. Normalization is mainly minimizing redundancy, insertion, deletion and update anomalies. Normalization achieve through functional dependency. Normalization is much type:
All categories are in sequential order:
1.1NF
2.2NF
3.3NF
4.BCNF
5.4NF
6.5NF

What is Functional Dependency in Normalization?

Answer:
Functional dependencies (FDs) are used to specify formal measures of the "goodness" of relational designs and used to define normal forms for relations. FDs are constraints that are derived from the meaning and interrelationships of the data attributes. FDs are derived from the real-world constraints on the attributes
For example: A set of attributes X functionally determines a set of attributes Y if the value of X determines a unique value for Y 
X-->Y holds if whenever two tuples have the same value for X, they must have the same value for Y If t1[X] =t2[X], then t1[Y] =t2[Y] in any relation instance r(R)
X-->Y in R specifies a constraint on all relation instances r(R)

What is 1 NF (Normal Form) in database?

Answer:
There is no repetition of values and data in table known as 1NF. In other words the 1NF disallows composite attributes, multivalued attributes, and nested relations, attributes whose values for an individual tuple are non-atomic.

What is Fully Functional dependency in database?

Answer:
A functional dependency X --> Y is full functional dependency if any attribute A removed from X. It means that the dependency does not hold any more then it is not Fully Functional dependence. Means each attribute is functionally dependent.

What is 2 NF (Normal Form) in database?

Answer:
A relation schema R is in 2NF when
1.It is in 1NF 
2.Every non-prime attribute A in R is fully functionally dependent on primary key.

What is Transitive functional dependency?

Answer:
If there a set of attribute Z that are neither a primary or candidate key and both X à Z  and Y à Z holds

What is 3 NF (Normal Form) in database?

Answer:
A relation schema R is in 3NF 
1.It is in 2NF 
2.No non-prime attribute A in R is transitively dependent on the primary key. Transitive dependent means if there a set of attribute Z that are neither a primary or candidate key and both X-->Z  and Y-->Z holds.

What is BCNF (Boyce-Codd Normal Form) in database?

Answer:
A relation schema R is in BCNF
1.It is in 3NF
2.Additional constraints that for every FD X -> A, X must be a candidate key

What is 4 NF (Normal Form) in database?

Answer:
A relation schema R is said to be in 4NF
1.It is in BCNF 
2.For every Multivalued dependency X --> Y that holds over R, Either  X is subset or equal to (or) XY = R. or X is a super key

What is 5 NF (Normal Form) in database

Answer:
A relation schema R is said to be in 5 NF
1.It is in 4NF
2.A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ..., Rn} that holds R, one the following is true Ri = R for some i. and The join dependency is implied by the set of FD, over R in which the left side is key of R.

What is key in Database?

Answer:
A database key is a attribute utilized to sort and identify data in some manner. 
There are many keys:
1. Primary keys
2. Foreign Keys
3. Candidate keys
4. Alternate keys
5. Conposite key

What is Primary Keys ?

Answer:
The primary key is a attribute of a relational table uniquely identifies the each tuple of a table or each record in the table. It can either be a normal attribute that is guaranteed to be unique. Such as Social Security Number in a table with no more than one record per person.

Examples: Imagine we have a employees table that contains a record for each employee at a organization. The employee's unique employee ID number would be a good choice for a primary key in the employees table. The employee's first and last name would not be a good choice, as there is always the chance that more than one employee might have the same name.

What is Foreign Keys ?

Answer:
These keys are used to create relationships between tables. Natural relationships exist between tables in most database structures.

Example:Let’s assume that the Departments table uses the Department Name column as the primary key. To create a relationship between the two tables, we add a new column to the Employees table called Department. We then fill in the name of the department to which each employee belongs. We also inform the database management system that the Department column in the Employees table is a foreign key that references the Departments table. The database will then enforce referential integrity by ensuring that all of the values in the Departments column of the Employees table have corresponding entries in the Departments table.

What is Alternate key, Candidate key and Composite key?

Answer:
Any number of attributes that are uniquely identifying a row in a table is “candidate key” for the table. We select one of the candidate key as Primary key. All candidate keys which are not chosen as "primary key" are “Alternate keys”. The key which uniquely identify the rows of the table and which is made up of more than one attribute is called “composite key”.
For Example: In a class we have to select Class Representative. So A, B, C and D stand for that post. So A, B, C and D are candidate for Class Representative so these are candidate key. We select B as Class Representative so B is primary key and A, C and D can be Class Representative but not selected as a Class Representative so they are alternative choice. So A, C and D are alternate key. When two students of class work together in a project then they are composite key for the class.