Chapter 2 - Getting Started with the SELECT Statement Flashcards

1
Q

Why should you explicitly indicate the schema name, such as in the FROM clause?

A
  1. It is considered best practice to always explicitly indicate the schema name.
  2. It can prevent you from ending up with a schema name that you did not intend to be used
  3. It can also remove the cost involved in the implicit resolution process (although the cost is minor).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False.

When using aliases, the convention is to use short names, typically one letter that is somehow indicative of the queried table, like E for Employees.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When you use an alias for a table name, is the table name visible for the duration of the query?

A

No. You must use the alias to refer to the table name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Although T-SQL supports using an asterisk (*) as an alternative to listing all attributes from the input tables, why is this considered bad practice?

A
  1. By returning more attributes than you really need, you can prevent SQL Server from using what would normally be considered covering indexes in respect to the interesting set of attributes.
  2. You send more data than is needed over the network, which can have a negative impact on system performance.
  3. The underlying table definition could change over time; even if , when the query was initially authored, * really represented all attributes you needed; it might not be the case anymore at a later point in time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the forms of aliasing an attribute in T-SQL?

A

The forms are:

  1. AS
  2. = .
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an irregular identifier?

A

An identifier that does not follow the rules for formatting identifiers; for example, it starts with a digit, has an embedded space, or is a reserved T-SQL keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the importance of the ability to assign attribute aliases in T-SQL? (Choose all that apply.)

  1. The ability to assign attribute aliases is just an aesthetic feature.
  2. An expression that is based on a computation results in no attribute name unless you assign one with an alias, and this is not relational.
  3. T-SQL requires all result attributes of a query to have names.
  4. Using attribute aliases, you can assign your own name to a result attribute if you need it to be different than the source attribute name.
A

2, 4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the mandatory clauses in a SELECT query, according to T-SQL?

  1. The FROM and SELECT clauses
  2. The SELECT and WHERE clauses
  3. The SELECT clause
  4. The FROM and WHERE clauses
A

3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which of the following practices are considered bad practices? (Choose all that apply.)

  1. Aliasing columns by using the AS clause
  2. Aliasing tables by using the AS clause
  3. Not assigning column aliases when the column is a result of a computation
  4. Using * in the SELECT list
A

3, 4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly