SQL SERVER Questions And Answers
What is an Entity?
The basic data item stored in database is called entity. An entity can be any object, item, place, person, concept, or activity about which data is stored.
What is an attribute?
An attribute is a property of an entity. It describes a part of an entity. Entity could have one or more attributes.
What is ER diagram?
An Entity Relationship Diagram is diagrammatic representation of the logical structure of a database system.
Describe the concept of keys.
An attribute that uniquely identifies a row is called candidate key. It is also called das surrogate key. Primary key
A candidate key that you choose to identify rows uniquely is called a primary key. Alternate key
If there are multiple candidate keys in a table, the candidate keys that are chosen as primary key are called the alternate keys. Composite key
When the key that uniquely identifies the rows of a table is made up of more than one attribute, it is called as a composite key.
Two tables can be related using a common attribute. When a primary key of one table is also available as an attribute in another related table it is called a foreign key.
What are joins?
Sometimes, data from multiple tables is to be displayed using select statement. For this purpose, the tables in use must have a column that is equated. This is termed as simple join or multiple join.
Sometimes, you might want to display all records from one table and some from another. This type of join is called an outer join. An outer join is only possible between two tables.
There are two types of outer join, namely left and right. In a left outer join, all the rows of the first table named in the FROM clause are displayed. In a right outer join all the rows from the second table mentioned in the FROM clause are displayed. In either case, all the matching rows from other table are displayed.
What is a sub query?
Sometimes the results of one query are dependant on the results of another query. For this purpose one query is nested inside another query, this is called as sub query.
What are the types of constraints?
You can enforce data integrity by using constraints. Constraints are divided in to five categories.
Primary key constraint
A primary key constraint is defined on a column are a set of columns whose values uniquely identify the rows in a table. It cannot contain null values.
Unique constraints are used to enforce uniqueness on non-primary key columns. It allows null values but only one row can have a null value. Multiple unique constraints can be created on a table.
Foreign Key constraint
You can use the foreign key constraint to remove the inconsistency in two tables when the data in the one table is dependant on the other table. Check constraint
It enforces domain integrity by restricting the values to be inserted in a column. It is possible to define multiple check constraints on a single column. These are evaluated in the order in which they are defined. Default Constraint
A default constraint can be use to assign a constant value to a column and the user need not insert values in to that column.
1. What is a rule?
The required integrity can be enforced by specifying a check constraint or by defining a rule. But check constraint modifies the table structure. The constraint can there fore be implemented using rules with out changing the table structure. This rule is applied before an insert or update statement . A rule must be bound to a column or a user-define d data type. This is done using stored procedure sp_bindrule. Rules do not apply to data that has already been inserted in the table. The existing values in tables do not have to meet the criteria specified by the rule.
What are indexes?
To speed up data retrieval indexes...
Please join StudyMode to read the full document