Chapter 1 - Foundations of Querying Flashcards
T-SQL supports two “not equal to” operators. What are they? Which one is standard?
<> and !=
<> is considered standard (part of the ISO/ANSI SQL standard).
Between the CAST and CONVERT functions, which is considered standard? What is the primary difference between the two?
CAST is a SQL standard to convert a source value to a target type.
The difference between the two, is the CONVERT function has a style argument that CAST does not.
TRUE or FALSE
Standard SQL uses a semi-colon to terminate statements.
TRUE
T-SQL does not make this a requirement for all statements, only in cases where there would otherwise be ambiguity of code elements (e.g. the WITH clause of a common table expression).
SQL attempts to represent a relation with a _______.
Attributes are represented as _______.
Tuples are represented as _______.
table
columns
rows
What are the mathematical branches that the relational model is based on?
Set Theory and Predicate Logic
What is the difference between T-SQL and SQL?
SQL is standard; T-SQL is a dialect of and extension to SQL that Microsoft implements in SQL Server.
If a set contains duplicates, what is it called?
Multiset or Superset
What is the downside of referring to a column by ordinal position in the ORDER BY clause?
There is a potential for error at some point if you decide to change the SELECT list and forget to change the ORDER BY list accordingly.
Therefore, the recommendation is to always indicate the names of the attributes that you need to order by.
How do you assign an alias to a column name?
Use the AS keyword to assign an alias.
A missing or unknown value is represented by a ______.
NULL
Name two aspects in which T-SQL deviates from the relational model.
- A relation has a body with a distinct set of tuples. While T-SQL allows tables to not have a key and allows for duplicates.
- T-SQL allows referring to ordinal positions of columns in the ORDER BY clause.
Why are the terms “field” and “record” incorrect when referring to column and row?
Because “field” and “record” describe physical things, whereas columns and rows are logical elements of a table.
Why is the term “NULL value” incorrect?
Because NULL isn’t a value; rather, it’s a mark for a missing value.
What non-relational elements are allowed in T-SQL queries?
T-SQL allows for:
- Duplicate values
- No Column Names
- Ordering results
- Using ordinal positions in the ORDER BY clause
Why is it important to use standard SQL code when possible and know what is standard and what isn’t? (Choose all that apply.)
A. It is not important to code using standard SQL.
B. Standard SQL code is more portable between platforms.
C. Standard SQL code is more efficient.
D. Knowing what standard SQL code is makes your knowledge more portable.
B and D