Вы находитесь на странице: 1из 5

SQL Interview Questions

Topic: Data Modeling



21. What is Data Model in RDBMS?
Ans: It's a collection of conceptual tools for describing the structure of database like data,
relationship among data, constraints etc.
22. What is an E-R Model in RDBMS?
Ans: This is an abstract way to describe the logical structure of any database. Different
symbols used in an E-R diagram is as follows:
rectangles: represent entity/entity sets.
ellipses: represent attributes.
diamonds: represent relationships among entities/entity sets.
lines: link attributes to entity sets and entity sets to relationships.
1. What is an Entity?
Ans: Entity is an object that exists and distinguishable from others. Ex: Student, Employee etc.
13. What is an Entity-Set?
Ans: It's a set of entities of the same type. Ex: All employees of a bank etc.

24. What is Relationship in RDBMS?
Ans: It is an association among two or more entities in a database.
42. What is Attribute?
Ans: Attribute describes entity. It is also called as field or column.
43. What is degree of a relation?
Ans: Total number of attributes (Columns) present in a relation (Table) called as degree of that
relation.
46. What are constraints in database?
Ans: Constraints are kind of restrictions that are applied to the database. For example an
integer attribute is restricted from 1-10 and not more than that. They provide the way to implement
SQL Interview Questions

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 havent been followed by the programmer.
1. What is Data Integrity in RDBMS?
Ans: Its a property of RDBMS which ensures Data Accuracy and Data Consistency.
2. What are different types of Data Integrity?
Ans: There are three types of Data Integrity as follows:
Entity Integrity
Domain Integrity
Referential Integrity
19. What is Domain in RDBMS?
Ans: The set of possible/permitted values an attribute can have, called as domain of that
attribute. Ex: Let say Age column in Student table must contain value in between 18 and 40. That means
18-40 is the domain of Age column.
20. How to ensure Domain Integrity in RDBMS?
Ans: Domain Integrity can be ensured by using either CHECK constraint or NOT NULL
constraint.


14. How Entity Integrity is ensured in RDBMS?
Ans: Entity Integrity can be ensured by using either Primary Key and Unique Key.
15. What is the difference between Primary Key and Unique Key?
Ans:
Primary key can not contain NULL value whereas Unique key can contain NULL value.
A table can have maximum one Primary key but more than one Unique key.
16. Differentiate between Simple Primary Key and Composite Primary Key.
Ans: If Primary Key is created on a single column/attribute, that is simple primary key
and if that is created on multiple columns/attributes, that is composite primary key.
17. Differentiate between Simple Unique Key and Composite Unique Key.
Ans: If Unique Key is created on a single column/attribute, that is simple unique key and
if that is created on multiple columns/attributes, that is composite unique key.
18. What is the similarity between Primary Key and Unique Key?
SQL Interview Questions

Ans: Both are used for unique identification of a particular record/row/tuple in a table
and can not contain duplicate value.

55. What is Candidate Key?
Ans: A candidate key is a combination of attributes that can be uniquely used to identify a
database record without any extraneous data. Each table may have one or more candidate keys. One of
these candidate keys is selected as the table primary key.

23. What is Foreign Key in RDBMS?
Ans: A Foreign Key is a field in a relational table that that refers to a primary key column in
another (referenced) table.
For example, say we have two tables, a CUSTOMER table that includes all
customer data, and an ORDER table that includes all customer orders. The intention here
is that all orders must be associated with a customer that is already in the CUSTOMER table. To do
this, we will place a foreign key in the ORDER table and have it relate to the primary key of the
CUSTOMER table.
The referencing and referenced table may be the same table, i.e. the foreign key
refers back to the same table. Such a foreign key is known as a self- referencing or recursive
foreign key.
48. What is the difference between Primary Key and Foreign Key?
Ans: Primary key uniquely identify a relationship in a database, whereas foreign key is the key
that is in other table and it has been referenced from the primary key from another table.
58. What is Alternate Key?
Ans: A candidate key is one that can identify each row of a table uniquely. Generally a
candidate key becomes the primary key of the table. If the table has more than one candidate key,
one of them will become the primary key, and the rest are called alternate keys.
59. What is Composite Key?
Ans: A key formed by combining at least two or more columns is called composite key.
SQL Interview Questions

60. What is Super Key?
Ans: A superkey is a combination of attributes that can be uniquely used to identify a
database record. A table might have many superkeys. Candidate keys are a special subset of
superkeys that do not have any extraneous information in them.
Example: Imagine a table with the fields <Name>, <Age>, <SSN>and <Phone Extension>.
This table has many possible superkeys. Three of these are <SSN>, <Phone Extension, Name>and
<SSN, Name>. Of those listed, only <SSN>is a candidate key, as the others contain information not
necessary to uniquely identify records.

48. What is extension and intension?
Ans: Extension is the number of tuples available in the table at any instance. Extension is
time dependent. Intension on the other hand is a constant value that gives the name, structure and
other values to the table and the constraints which are laid on it.
SQL Interview Questions

Вам также может понравиться