Top 50 Dbms+rdbms Interview Questions You Must Prepare 19.May.2024

Data independence tells about the independence of the data inside the application. It usually deals with the storage structure and represents the ability to modify the schema definition. It doesn’t affect the schema definition which is being written on the higher level. There are two types of data independence:

  1. Physical data independence: it allow the modification to be done in physical level and doesn’t affect the logical level.
  2. Logical data independence: it allow the modification to be done at logical level and affects the view level.

NOTE: Logical Data Independence is more difficult to achieve.

SQL IN operator is used to see if the value exists in a group of values. For instance the below

SQL checks if the Name is either 'David' or 'Craig' SELECT * FROM wbEmployee WHERE name IN ('David','Craig') Also you can specify a not clause with the same. SELECT * FROM wbEmployee WHERE age NOT IN (30,25)

Unlike Relational systems in System R 

  • Domains are not supported 
  • Enforcement of candidate key uniqueness is optional 
  • Enforcement of entity integrity is optional
  • Referential integrity is not enforced

ACID stands for Atomicity, Consistency, Isolation and durability and it plays an important role in the database. These properties allow the database to be more convenient to access and use. This allows data to be shared more safely in between the tables. If these properties are not being implemented then the data will become inconsistent and inaccurate. It helps in maintaining the accuracy of the data in the database.

The storage structures and access methods used by database system are specified by a set of definition in a special type of DDL called data storage-definition language.

It is a collection (set) of entities that have same attributes.

The two principal rules for the relational model are as follows:

  1. Entity integrity: this is used to maintain the integrity at entity level
  2. Referential integrity: it is used to maintain integrity on all the values which have been referenced.

The differences between them are as follows:

  • Entity integrity tells that in a database every entity should have a unique key; on the other hand referential integrity tells that in the database every table values for all foreign keys will remain valid.
  • Referential integrity is based on entity integrity but it is not the other way around.

For example: if a table is present and there is a set of column out of which one column has parent key set then to ensure that the table doesn’t contain any duplicate values, a unique index is defined on the column that contains the parent key.

There are three major relationship models:-

  • One-to-one
  • One-to-many
  • Many-to-many

Normalization is a process of analyzing the given relation schemas according to their functional dependencies. It is used to minimize redundancy and also minimize insertion, deletion and update distractio

A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose.

Analytical processing databases are not very normalized. The operations which are used are read most databases. It is used to extract the data that are ancient and accumulated over long period of time. For this purpose de-normalization occurs that provide smart business applications. Dimensional tables in star schema are good example of de-normalized data. The de-normalized form must be controlled while extracting, trforming, loading and processing. There should be constraint that user should not be allowed to view the state till it is consistent. It is used to increase the performance on many systems without RDBMS platform.

 

This language is to specify the internal schema. This language may specify the mapping between two schemas.

It is an association among two or more entities.

  1. Relationship Set - The collection (or set) of similar relationships.
  2. Relationship Type - Relationship type defines a set of associations or a relationship set among a given set of entity types.
  3. Degree of Relationship Type - It is the number of entity type participating.

There are many relational operators that are used to perform actions on relational database. These operators are as follows:

  • union operator: that combines the rows of two relations and doesn’t include any duplicate. It also removes the duplicates from the result.
  • intersection operator: provides a set of rows that two relations have in common.
  • difference operator: provide the output by taking two relations and producing the difference of rows from first that don’t exist in second.
  • cartesian product: is done on two relations. It acts as a cross join operator.

System R was designed and developed over a period of 1974-79 at IBM San Jose Research Center. It is a prototype and its purpose was to demonstrate that it is possible to build a Relational System that can be used in a real life environment to solve real life problems, with performance at least comparable to that of existing system.
Its two subsystems are

  • Research Storage
  • System Relational Data System.

The database and DBMS software together is called as Database system.

  • Primary key uniquely identify a relationship in a database, whereas foreign key is the key that is in other relation and it has been referenced from the primary key from other table.
  • Primary key remains one only for the table, whereas there can be more than one foreign key.
  • Primary key is unique and won’t be shared between many tables, but foreign key will be shared between more than one table and will be used to tell the relationship between them.

Non-first normal form (NFA) – it describes the definition of the database design which is different from the first normal form. It keeps the values in structured and specialized types with their own domain specific languages. The query language used in this is extended to incorporate more support for relational domain values by adding more operators.

Data independence specifies that the application is independent of the storage structure and the access strategy of data. It me the ability to modify the schema definition in one level should not affect the schema definition in the next higher level.
There are two types of data independence:

  • Physical data independence
  • Logical data independence

  • Redundancy is controlled.
  • Unauthorised access is restricted.
  • Providing multiple user interfaces.
  • Enforcing integrity constraints.
  • Providing backup and recovery.

The collections of entities of a particular entity type are grouped together into an entity set.

The are three levels of abstraction:

  • Physical level: The lowest level of abstraction describes how data are stored.
  • Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data.
  • View level: The highest level of abstraction describes only part of entire database.

  • Extension: It is the number of tuples present in a table at any instance. This is time dependent.
  • Intension: It is a constant value that gives the name, structure of table and the constraints laid on it.

  • Data redundancy & inconsistency.
  • Difficult in accessing data.
  • Data isolation.
  • Data integrity.
  • Concurrent access is not possible.
  • Security Problems.

VDL (View Definition Language): It specifies user views and their mappings to the conceptual schema.

SQL stands for Structured Query Language.SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems. SQL statements are used to retrieve and update data in a database.

Main difference between a simple file and database that database has independent way (SQL) of accessing information while simple files do not File meets the storing, managing and retrieving part of a database but not the independent way of accessing data. Many experienced programmers think that the main difference is that file can not provide multi-user capabilities which a DBMS provides. But if we look at some old COBOL and C programs where file where the only me of storing data, we can see functionalities like locking, multi-user etc provided very efficiently. So it’s a matter of debate if some interviewers think this as a main difference between files and database accept it… going in to debate is probably loosing a job.

Functional Dependency is the starting point of normalization. It exists when a relation between two attributes allows you to uniquely determine the corresponding attribute's value.

Table consists of some properties that are known as attributes. These consist of the representation of entity in the table. They are represented by columns in the table. Entity is referred to the store data about any particular thing. It is the smallest unit inside the table.

Relational database me the relationship between different databases. In relational database user can store and access all the data through the tables which are related to each other. Relationship between the store data is called base relations and implementation of it is called as tables. Whereas, relations which don’t store the data, but can be found out by applying relational operations on other relations are called as derived relations. When these are implemented they are termed as views or queries. Derived relations are more useful then base relation, as they can have more information from many relations, but they act as a single relation.

ORDER BY clause helps to sort the data in either ascending order to descending order.

  • Ascending order sort query : SELECT name,age FROM pcdsEmployee ORDER BY age ASC.
  • Descending order sort query : SELECT name FROM pcdsEmployee ORDER BY age DESC.

Index is a way to provide quick access to the data and structure. It has indexes maintain and can be created to combine attributes on a relation. Index allows the queries to filter out the searches faster and matching data can be found earlier with simplicity. For example it is same as the book where by using the index you can directly jump to a defined section. In relational database there is a provision to give multiple indexing techniques to optimize the data distribution.

  • Data redundancy and inconsistency.
  • Difficult in accessing data.
  • Data isolation.
  • Data integrity.
  • Concurrent access is not possible.
  • Security Problems.

Cardinality is important and used to arrange the data inside the database. It is related to the design part and need to be properly used in database. It is used in E-R diagrams and used to show the relationship between entities/tables. It has many forms like the basic is one to one, which associate one entity with another.

Second is one to many: which relates one entity with many entities in a table.
Third is many to many M: N that allows many entities to be related to many more.
Last is many to one: that allows the many entities to be associated with one entity.

Domain describes possible values grouped together that can be given for an attribute. It is considered the same way as a constraint on the value of attribute. A domain can be attached to an attribute but only if the attribute is an element of specified set. For example: XYZ doesn’t fulfill the domain constraint but the integer value as 899 fulfills the criteria of domain constraint. Hence, domain is of high importance.

This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes.

There are two Integrity rules.

  1. Entity Integrity: States that Primary key cannot have NULL value
  2. Referential Integrity: States that Foreign Key can be either a NULL value or should be Primary Key value of other relation.

Normalization is very essential part of relational model. It consists of set of procedures that eliminates the domains that are non-atomic and redundancy of data that prevents data manipulation and loss of data integrity. Normal forms are the common form of normalization. It helps in reducing redundancy to increase the information overall. It has some disadvantages as it increases complexity and have some overhead of processing.

Data Definition Language : A data base schema is specifies by a set of definitions expressed by a special language called DDL.

 

A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words, there is no stored file that direct represents the view instead a definition of view is stored in data dictionary.

Growth and 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.

It is a collection of all entities of particular entity type in the database.

Insert statement is used to insert new rows in to table. Update to update existing data in the table. Delete statement to delete a record from the table. Below code snippet for Insert, Update and Delete :-

INSERT INTO wbEmployee SET name='maxwell',age='22';
UPDATE wbEmployee SET age='22' where name='maxwell';
DELETE FROM wbEmployee WHERE name = 'david';

Relation in the relational database model is defined as the set of tuples that have the same attributes. Tuple represents an object and also the information that the object contains. Objects are basically instances of classes and used to hold the larger picture. Relation is described as a table and is organized in rows and columns. The data referenced by the relation come in the same domain and have the same constraints as well. Relations in the relational database model can be modified using the commands like insert, delete etc.

Below SQL selects employees born between '01/01/1995' AND '01/01/1978' as per mysql

SELECT * FROM wbEmployee WHERE DOB BETWEEN '1995-01-01' AND '2011-09-28'

An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set.

There are three levels of data abstraction that is present in database model and these are as follows:

  • physical level: it is the lowest level that describes how data is stored inside the database.
  • logical level: it is the next higher level in the hierarchy that provides the abstraction. It describes what data are stored and the relationship between them.
  • view level : it is the highest level in hierarch that describes part of the entire database. It allows user to view the database and do the query.

Denormalization is the process of boosting up database performance and adding of redundant data which helps to get rid of complex data.

There are four types of database languages:

  • Data Definition Language (DDL) e.g. CREATE, ALTER, DROP etc.
  • Data Manipulation Language (DML) e.g. SELECT, UPDATE, INSERT etc.
  • DATA Control Language (DCL) e.g. GRANT and REVOKE.
  • Traction Control Language (TCL) e.g. COMMIT and ROLLBACK.

Constraints are kind of restrictions that are applied to the database or on the domain of an attribute. For example an integer attribute is restricted from 1-10 and not more than that. They provide the way to implement the business logic and the rules in database. In database it can be implemented in the form of check constraints that checks for the rules that haven’t been followed by the programmer. Constraint also used to restrict the data that can be stored in the relations. Domain constraint can be applied to check the domain functionality and keep it safe..

It is a particular property, which describes the entity.