EXERCISES

2.1 What’s a type? What’s the difference between a domain and a type?

2.2 What do you understand by the term selector? And what exactly is a literal?

2.3 What’s a THE_ operator?

2.4 Physical representations are always hidden from the user: True or false?

2.5 This chapter has touched on several more logical differences (refer back to Chapter 1 if you need to refresh your memory regarding this important notion), including:

argument

vs.

parameter

database

vs.

DBMS

foreign key

vs.

pointer

generated type

vs.

nongenerated type

relation

vs.

type

type

vs.

representation

user defined type

vs.

system defined type

user defined operator

vs.

system defined operator

What exactly is the logical difference in each of these cases?

2.6 Explain in your own words the difference between the concepts scalar and nonscalar.

2.7 What do you understand by the term coercion? Why is coercion a bad idea?

2.8 Why doesn’t domain check override make sense?

2.9 What’s a type generator?

2.10 Define first normal form. Why do you think it’s so called?

2.11 Let X be an expression. What’s the type of X? What’s the significance of the fact that X is of some type?

2.12 Using the definition of the REFLECT operator in the body of the chapter (section WHAT’S A TYPE?) as a template, define a Tutorial D operator that, given an integer, returns the cube of that integer.

2.13 Let LENGTH be a user defined type, with the obvious semantics. Use Tutorial D to define an operator that, given the length of two adjacent sides of a rectangle, returns the corresponding area.

2.14 Give an example of a relation type. Distinguish between relation types, relation values, and relation variables.

2.15 Use SQL or Tutorial D or both to define relvars P and SP from the suppliers-and-parts database. If you give both SQL and Tutorial D definitions, identify as many differences between them as you can. What’s the significance of the fact that relvar P (for example) is of a certain relation type?

2.16 With reference to the departments-and-employees database from Chapter 1 (see Figure 1-1), suppose the attributes are of the following user defined types:

     DNO    : DNO
     DNAME  : NAME
     BUDGET : MONEY
     ENO    : ENO
     ENAME  : NAME
     SALARY : MONEY

Suppose departments also have a LOCATION attribute, of user defined type CITY (say). Which of the following scalar expressions are valid? For those that are, state the type of the result; for the others, give an expression that will achieve what appears to be the desired effect.

  1. LOCATION = ‘London’

  2. ENAME = DNAME

  3. SALARY * 5

  4. BUDGET + 50000

  5. ENO > ‘E2’

  6. ENAME || DNAME

  7. LOCATION || ‘burg’

2.17 It’s sometimes suggested that types are really variables, in a sense. For example, employee numbers might grow from three digits to four as a business expands, so we might need to update “the set of all possible employee numbers.” Discuss.

2.18 A type is a set of values and the empty set is a legitimate set; thus, we might define an empty type to be a type where the set in question is empty. Can you think of any uses for such a type?

2.19 In the relational world, the equality operator “=” applies to every type. By contrast, SQL doesn’t require “=” to apply to every type, and it doesn’t fully define the semantics in all of the cases where it does apply. What are the implications of this state of affairs?

2.20 Following on from the previous exercise, we can say that if v1 = v2 evaluates to TRUE in the relational world, then executing some operator Op on v1 and executing that same operator Op on v2 always has exactly the same effect, for all possible operators Op. But this is another precept that SQL violates. Can you think of any examples of such violation? What are the implications?

2.21 Why are pointers excluded from the relational model?

2.22 The Assignment Principle—which is very simple, but fundamental—states that after assignment of the value v to the variable V, the comparison V = v evaluates to TRUE (see Chapter 5). Yet again, however, this is a precept that SQL violates (fairly ubiquitously, in fact). Can you think of any examples of such violation? What are the implications?

2.23 Do you think that types “belong to” databases, in the same sense that relvars do?

2.24 In the first example of an SQL SELECT expression in this chapter, I pointed out that there was no terminating semicolon because the expression was an expression and not a statement. But what’s the difference?

2.25 Explain as carefully as you can the logical difference between a relation with a relation valued attribute (RVA) and a “relation” with a repeating group.

2.26 What’s a subquery?

2.27 To repeat from Exercise 2.19: In the relational world, the equality operator “=” applies to every type. But what about type BOOLEAN? And what about SQL’s row and table types?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.241