Measure Up Create Database Objects Flashcards
What are the two types of DML triggers?
After
Instead of
What should you use to ensure that the underlying table structure cannot be modified?
With Schemabinding
What should you use to ensure that no modification can be made that would prevent a row currently included in the view from being excluded from the view?
Note: when a query is issued against this view that attempts to change the value of the column data, an error occurs.
With Check Option
What should you use to hide the definition of how a view was coded?
With Encryption
Which constraint is used to uniquely identify each record and not allow any blank values?
Primary Key constraint
What should you use to ensure that only metadata for the view can be read, not that of the underlying base tables?
With View_Metadata
Which clause enforces the restriction that only rows that match the condition defined by the view can be modified through the view?
With Check Option
List the statement Syntax order used to turn off constraint checking
Alter [Table]
NoCheck Constraint
List the statement syntax order used to fix a table accidentally saved as part of the incorrect schema.
Alter [Schema]
Transfer [Table]
Which function can be used within a trigger to determine whether an Update or Insert statement has attempted to modify the value in a column?
Update()
**Note: you pass the name of the column to the function within the parentheses
List the statement Syntax order used to modify an existing column in a table.
Alter [Table]
Alter [Column]
Which command should be used to remove a table?
Drop [Table]
What commands are used to remove rows from a table, but not to delete the entire table structure?
Note: 2 commands can be used.
Truncate [Table]
Delete [Table]
Can an index be created on a view that is based on a query that performs a Right Join?
No
Note: A right join is an an outer join. You cannot create an index on a view that is based on a query that performs an outer join.
What statement should be used to combine the result sets and return all the records from both Select statements?
Union All
What command should be used to remove a view?
Drop View
What command should be used to remove rows from a view?
Delete View
Can you use Alter [Column] to rename a column name?
No
Note: To rename a column, you must execute the sp-rename stored procedure.
List the statement Syntax order used to add new columns/fields to a pre-existing table?
Alter [Table]
Add [Column(s)]
What commands should you use if you want to create a Table in a Schema that doesn’t exist?
Create [Schema]
Create [Table]
Note: Because the Schema doesn’t exist, both should be created.
A foreign key constraint can be defined in the column definition by using either what keyword or clause?
References
Foreign Key References
Which clause causes the data to be formatted with each table represented by an element and each column represented as an attribute?
For XML Auto clause
Which clause is used to identify the name of the outer element?
For XML Path
What view hint should be used to force the query optimizer to use indexes built on the view?
NOEXPAND view hint
What view hint should be used to force the execution plan to ignore the index?
Force_Scan view hint
Which command is used to modify existing columns in a table but not create new ones?
Alter [Column]
Note: Use Add [Column] to add a new column
To create a column that does not allow NULL values, which keyword is used?
Not Null
What keyword is used to create a computed column and specifying the formula used to calculate the column in parentheses?
As
Note: looks like this
Column As (Column + Column)
Which trigger should be used to update view when more than one base table needs to be updated?
Instead Of
If you want to ensure that when a record is deleted in the parent table of the relationship, the value of the Foreign Key is updated. What Referential Integrity option is used for this task?
On Delete Set Default
Note: This will ensure that the value of the Foreign Key is updated.
What keyword can be used in a Correlated Subquery to filter the results set so that it contains only the rows that match at least one row in the other table?
Exists
What type of integrity is used to validate entries for specific columns?
Domain Integrity
What type of integrity is used to define a row as a unique entity?
Entity Integrity
What type of integrity is used to define relationships between tables?
Referential Integrity