Module 2 Flashcards
What are the standard BIG FIVE aggregate functions? What are these functions used for?
- These functions are MIN(), MAX(),
- SUM(), AVG(), and COUNT().
- SQL Server also provides additional aggregate functions.
- Aggregate functions are used (many times in conjunction with GROUP BY and
- HAVING) to summerize data.
What types of code can be used in a stored procedure?
- T-SQL or Transact SQL and CLR or
- Common Language Runtime can be used to program stored procedures
If you user an aggregate function within a view, that view will no longer be updatable, which means you will only be able to use that view to retrieve or SELECT data. Why?
- Aggregate data cannot map back to a particular row in underlying tables,
- so the DBMS will not know how to update the underlying table to prioduce the indicated changes in the aggregated data.
What is the difference between Data Control Language (DCL), Data Definition Language (DDL) and Data Manipulation Language (DML)?
- All three are components of SQL.
- DCL - configures local security in the database allowing you to create users and roles as well as grant permissions to database objects
- DDL - provides the facility to create and manage the logical schema in a database.
- DML - provides the ability to query and manipulate data nad is the most widely used of the three components of SQL.
What is the difference between a declarative programming language and an imparative programming language?
- Using an imperative langauge you want to specify what you want to happen step by step.
- In a declarative langauge you organize set of statements that describe what you want to happen.
- In a declarative language you do not specify what you want to happen step by step.
4.
Why is an inline UDF sometimes called a VIEW that can accept parameters?
can return a table or set of data based on a parameters
How do you change the database context?
This is achieved by USE <database></database>
What is the primary purpose of a stored procedure and how does a stored procedure differ from a trigger?
- Stored procedures can be used to define an APL encapsulate complex logic, and provde flow control or repetition (more complicated program logic.)
- A trigger can contain similar code, but the code excutes when specific events happen (related to insert, update, delete, and logon.).
What is the difference between a correlated subquery and a non-correlated subquery? What are the uses of each?
- A correlated subquery is a subquery that references the columns in the outer query. In a correlated subquery,
- the inner query runs one time for each row in the outer subquery. In a non-correlated subquery on the other had this does not happen.
- The inner query runs once.
- Correlated subqueries are used to create complicated queries to accomplish data retrieval tasks that cannot be accomplished other ways (such as using a join.)
- A non-correlated subquery is used to create more dynamic code that does not require the author of the code to know all the intermediate values in the database.
The correct usages for UNION, UNION ALL, EXCEPT, and INTERSECT.
- combine multiple queries using the set operators
- Set operators combine results from two or more queries into a single result set.
What types of constraints did we talk about in SQL Server?
- We talked about check constraints,
- NOT NULL constraints,
- PRIMARY KEY constraints, and
- FOREIGN KEY constraints (as part of RELATIONAL INTEGRITY constraints).
The process for performing all joins (INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN).
- An SQL JOIN clause is used to combine rows from two or more tables,
- based on a common field between them.
What is a qualified name?
- a combination of identifiers that uniquely defines the location of a database object.
- constructed by using up to four identifiers that represent the logical structure
- represents hierarchy of the SQL Server instance, the database name, the database schema, and the database object.
What is a Partitioned View?
- This is a view which displays horizontally divided data from a set of member tables across one or more servers,
- making the data appear as if it is from one table
What is the database operation you would choose to merge and retrive data stored in more than one table or view?
This is a JOIN peration (either INNER, LEFT OUTER, RIGHT OUTER, or FULL OUTER)
describe the TOP clause
- used to specify the number of records to return.
- ery useful on large tables with thousands of records.
- Returning a large number of records can impact on performance.
What is the purpose of ranking functions and what are the two different ranking functions? What is teh difference in these two functions?
They provide simple analytics such as statistical ordering and segmentation.
The two different ranking functions are RANK() and DENSE_RANK()
RANK() will create gaps when there is a tie
DENSE_RANK() will assign the same number to ties, but will not create gaps.
What is an indexed view? How does Microsoft implement the view in order to allow it to be indexed?
- An indexed view is a view where the data can be indexed just like a table.
- In order for this to work, Microsoft “materializes” the view using as temporary table which is then indexed.
What is Transact-SQL and who developed it?
a variabt of SQL that was developed by Microsoft and Sybase
Is SQL an imperative or declarative programming language?
declarative
What types or joins are available in SQL Server 2012? What is each used for?
- JOIN or INNER JOIN - This join is used to retrieve data that matches based on the join condition specified in the ON clause.
- LEFT OUTER JOIN - This join is used to retrieve all data from the left table and the data that matches in the right table based on the join condition specified in the ON clause.
Wht are the three types of programming objects you can create in Microsoft SQL, Server and what are the three types of functions suppored in Microsoft SQL Server?
- The three pgorammable objects are Stored Procedures, Functions, and Triggers.
- The three types of functions are Scalar, Inline table-valued, Multistatement table-valued
Describe why you would use the data control language componenet of the SQL programming language.
- SQL DCL statements can be used to create logical security objects and to grant or revoke permissions.
- To connect to a database, a user must be able to authenticate using either a Windows or SQL Server login.
- SQL Server can be configured to use either Windows authentication (which lerverages the host operating system),.
- a local SQL Server login usign SQL Server authentication,
- or bother SQL Server and Windows authentication.
How do you create a column or database name alias?
- This is done by specifying AS and then the alias name after the column in the SELECT statement or
- the table name in the FROM clause.
- For tables the AS can be omitted and you can just follow the table name wityh a space and then the alias name in the FROM clause.