CIS275 - Chapter 10: Complex Data Types Flashcards
1
Q

A

2
Q

A

3
Q

A

4
Q

A

5
Q

A

6
Q
- A SET is defined with the SET keyword followed by a list of elements.
- SET values are specified as strings containing elements separated by commas. The string cannot contain blanks.

A
- SET values can be compared with string functions.

7
Q

A

8
Q
- The QuarterlySales column is an array of four integers, representing employee sales in each of four quarters.
- Array values are specified as elements separated by commas and within braces.

A
- QuarterlySales[2] refers to the second element of each value in the QuarterlySales column.

9
Q

A

10
Q

A

11
Q

A

12
Q

A

13
Q
- The Library table contains a Book column with JSON type.
- JSON_OBJECT() converts element names and data to a JSON document, stored in the internal MySQL format.
- The SELECT statement retrieves JSON documents. Each document appears on one line.

A
- The SELECT statement uses JSON_EXTRACT() to extract data from the Book column. Only “Tom Sawyer” has a Pages element.

14
Q

A

15
Q
- A point in two dimensions has X and Y coordinates. POINT(22 8) is WKT format.
- A WKT linestring is a series of connected line segments. Points are separated by commas.

A
- A WKT polygon is a series of points, separated by commas and enclosed in an extra set of parentheses.
- WKT polygons can have holes. The first polygon is the outer boundary and the second is a hole.

16
Q

A

17
Q

A

18
Q
- Location is a spatial column. Coordinates are latitude and longitude in spatial reference system 4326.
- INSERT statement converts WKT to internal format with ST_POINTFROMTEXT(), which requires an SRID parameter.

A
- SELECT statement converts internal format to WKT with ST_ASTEXT().

19
Q

A

20
Q
- The Capital table contains state capitals. Location values are latitude and longitude in spatial reference system 4326.
- ST_DISTANCE() computes each capital’s distance in meters to 40° latitude and -100° longitude. MySQL uses the British spelling ‘metre’ rather than the American spelling ‘meter’.

A
- The WHERE clauses uses ST_X() to get the Location’s X-coordinate. Spatial data must be converted to numeric data to use a comparison operator.
- Sacramento and Des Moines both have X-coordinates < 42. Distance is displayed in meters.

21
Q

A

22
Q

A

23
Q

A

24
Q

A

25
Q

A

26
Q
- The supertype must specify NOT FINAL to allow subtypes.
- GlobalAddressType is a subtype of AddressType with an additional property.
- GlobalAddressType overrides the FormatAddress function.

A
- The global FormatAddress function adds the country the formatted address.

27
Q

A
