Chapter 1 : Foundation of Querying Flashcards
Predicate Logic
• A predicate is an expression that when attributed to some object, makes a proposition either true or false.
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 the dialect of and extension to SQL that Microsoft implements in its RDBMS - SQL Server
Multiset
A multiset (also known as a bag or a superset) in many respects is similar to a set, but can have duplicates.
Name two aspects in which T-SQL deviates from the relational model.
A relation has a body with a distinct set of tuples. A table doesn’t have to have a key. T-SQL allows referring to ordinal positions of columns in the ORDER BY clause.
Explain how you can address the two items in question 1 and use T-SQL in a relational way.
Define a key in every table. Refer to attribute names - not their ordinal position - 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.
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
It is not important to code using standard SQL. F
§ It is important to use standard code.
Standard SQL code is more portable between platforms. C
§ Use of standard code makes it easier to port code between platforms because fewer revision are required.
Standard SQL code is more efficient.
§ There’s no assurance that standard code will be more efficient.
Knowing what standard SQL code is makes your knowledge more portable C
§ When using standard code, you can adapt to a new environment more easily because standard code elements look similar in the different platforms.
Which of the following is not a violation of the relational model?
A) Using ordinal position for columns.
B) Returning duplicate rows.
C) Not defining a key in a table.
D) Ensuring that all attributes in the result of a query have names.
Using ordinal position for columns. F
§ A relation has a header with a set of attributes, and tuples of the relation have the same heading. A set has no order, or ordinal positions do not have meaning and constitute a violation of the relational model. You should refer to attributes by their name.
Returning duplicate rows. F
§ A query is supposed to return a relation. A relation has a body with a set of tuples. A set has no duplicates. Returning duplicate rows is a violation of the relational model.
Not defining a key in a table. F
§ Not defining a key in the table allows duplicate rows in the table, and like the answer to B, what’s a violation of the relational model.
Ensuring that all attributes in the result of a query have names. C
§ Because attributes are supposed to be identified by name, ensuring that all attributes have name is relational, and hence not a violation of the relational model.
What is the relationship between SQL and T-SQL?
A) T-SQL is the standard language and SQL is the dialect of Microsoft SQL Server.
B) SQL is the standard language and T-SQL is the dialect in Microsoft SQL Server. C
C) Both SQL and T-SQL are standard languages.
D) Both SQL and T-SQL are dialects in Microsoft SQL Server.
T-SQL is the standard language and SQL is the dialect of Microsoft SQL Server. F
§ T-SQL isn’t standard and SQL isn’t a dialect in Microsoft SQL Server.
SQL is the standard language and T-SQL is the dialect in Microsoft SQL Server. C
§ SQL is standard and T-SQL is a dialect in Microsoft SQL Server.
Both SQL and T-SQL are standard languages. F
§ T-SQL isn’t standard.
Both SQL and T-SQL are dialects in Microsoft SQL Server. F
§ SQL isn’t a dialect in Microsoft SQL Server.
Name all the steps of SQL keyed in order
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
Name all the steps in the logical query process
FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY
What is the difference between WHERE and HAVING clause?
The WHERE clause is evaluated before rows are grouped, and therefore is evaluated per row. The HAVING clause is evaluated after rows are grouped, and therefore is evaluated per group.
Why are you not allowed to refer to a column alias defined by the SELECT clause in the WHERE clause?
Because the WHERE clause is logically evaluated in a phase earlier to the one that evaluates the SELECT clause.