5052 EXAM Flashcards
What are the 5 advantages of stored procedures?
- Reusable and Consistent
- Security and Control
- Modular
- Speed
- Network
What are 3 disadvantages of stored procedures?
- Server load
- Single Query Plan
- Not portable
What symbol is used to denote a variable or parameter?
@
What keyword is used to call a stored procedure?
EXECUTE
How do you suppress row count information in a stored procedure?
SET NOCOUNT ON
Is it possible to have multiple outputs in a stored procedure?
Yes
What is a scalar function?
A function that returns a single value
What is the rule with brackets around the parameter list regarding procedures and functions?
Stored Procedures = Optional
Functions = Required
How do you specify the return in a function?
- RETURNS (DataType) after the parameter list
- RETURN (variable) at end of function body
Which can be used as an expression, stored procedure or function?
Function
What does ACID stand for?
Atomicity
Consistency
Isolation
Durability
What does atomicity mean?
Entire transaction either succeeds or fails
What does a consistent transaction ensure?
The system will return to the state it was in before the transaction
Which ACID principle(s) apply to transactions still executing?
Isolation
Which ACID principle(s) apply to completed transactions?
Atomicity, Consistency, and Durability
How do you start a transaction?
BEGIN TRANSACTION
How do you specify to reverse a transaction?
ROLLBACK TRANSACTION
How do you specify to save the changes made by a transaction?
COMMIT TRANSACTION
What are 2 types of locks?
- Exclusive Lock
- Shared Lock
When does the system use an exclusive lock?
INSERT, UPDATE, DELETE
When does the system use a shared lock?
Read functions, like SELECT
What are 3 ways to prevent deadlocks?
- Control the flow (stored procedures)
- Keep transactions small
- Consolidate code
What is the rule for default values for stored procedure parameters?
Must be constants or NULL
What does SCOPE_IDENTITY() return?
Last Identity value created in scope
When specifying parameters by name in an execute statement, what side of the ‘=’ is the parameter?
Left
What is the best practice regarding conditional statements?
Use BEGIN and END the same way you would braces
How do we short-circuit a stored procedure?
RETURN
How do we handle errors with stored procedures?
SET XACT_ABORT ON
What is an inline view?
Subquery in a FROM clause
What keyword is used to create a CTE?
WITH
What does CTE stand for?
Common Table Expression
What are the 3 categories of WINDOW functions?
- Rank
- Aggregate
- Analytic
What keyword is used to define WINDOW functions?
OVER
What is an issue when using RANK()?
Causes gaps if identical values (1, 1, 3)
How do you solve the problems associated with RANK()?
DENSE_RANK()
What are the 3 analytic functions?
- LEAD
- LAG
- FIRST_VALUE
What does SSRS stand for?
SQL Server Reporting Services
What does bottom-up dimensional modelling entail?
Start by building data marts for specific functions, then integrate into data warehouse
Are backups important for a data warehouse?
No, it isn’t the primary source of the data
What is different with the queries in an OLTP vs a Data Warehouse?
Data Warehouse queries are much larger and more complex
What are data warehouses optimized for?
Reads
What is a major difference between a star-schema dimensional model and a snowflake-schema?
Snowflake-schema dimensions can reference other dimensions
What is a table value function?
A function that returns a table
What kind of data is held in a fact table?
Quantitative
What kind of data is held in a dimension table?
Qualitative
What is another word for quantitative data in a fact table?
Measure
Which table in a data warehouse helps define granularity?
Dimension Table
What granularity is more detailed?
Fine grain
What granularity is aggregated data?
Coarse grain
What does increasing granularity mean for rows?
They increase as well
What is a major constraint of granularity?
Data sources
What are the 4 steps in creating a dimensional model?
- Identify process to be tracked
- Define granularity
- Define dimensions
- Define facts and measures
What is the key for a fact table?
Alternate key consisting of all the foreign keys together
What is the most common and most fundamental dimension?
Date Table
What kind of key does the date dimension use?
Smart Key
What is a slowly changing dimension?
Any non-key attribute can change over time
What is a Type 0 SCD?
No attributes may ever change over time
What is a Type 1 SCD?
Non-key attributes can overwrite the original value when changed
What is a Type 2 SCD?
Non-key attributes change by adding a new record
What must be added to a Type 2 SCD dimension table?
Start and End date
What does ETL stand for?
Extract, Transform, Load
What is SSIS?
SQL Server Integration Services
What is a control table?
Logs start and finish of ETL tasks