w2d3 Flashcards

1
Q

What do queries do

A

get output in the way you need it

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

subqueries

A

return a table (special ones can return a single constant)
can act as tables in a from
can be combined into a single table
can be used with special modifiers
ARE MOST USEFUL WHEN DEALING WITH A SINGLE TABLE

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

In clause

A

used instead of where when you have a relation

because subqueries return tables as a default and you can not use an equality between an attribute and a relation

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

ANY/SOME

A
  • works with subqueries that give a single column

WHERE xxx condition ANY(Is true if xxx meets the condition for one or more results of a query)

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

All

A

like ANY/some but true if xxx meets the condition for all results of the subquery

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

EXISTS/NOT EXISTS

A

true if sub query produces one or more rows/records

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

ALIAS/PREFIXES

A

Each table can be given an alias in the FROM clause
FROM TableA aliasA, TableB aliasB
- aliases typically one or two characters
- alias is used to prefix attributes from a particular table in cases where the same attribute name is used in both tables
- where attribute names are unique they do not need prefixes

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

Simple Join

A

attributes from both tables

common attributes prefixed

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

Foreign keys always….

A

point at a unique set of attributes, usually a primary key

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

What can sort a join

A

any of the attributes defined in the select clause

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

Inner join

A

contains records in result only where corresponding records were found in both tables

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

Full outer join

A

Contains records in result where any records were found in either input table, nulls placed in missing attributes

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

Left Outer Join

A

contains records in results where records were in the first input table
- place nulls in result attributes that are missing because of a missing record in the second input table

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

By making all joins as multi-table queries

A

ensures you make your intentions explicit

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

joining tables

A

requires both tables have the same structure

  • same # of columns
  • corresponding columns are of the same type and length
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

INSERT

A

enters one or more new records into an exisiting table
- if attribute names not specified insert assumes the values are in the order defined in the table definition
(will fail if attribute not given a value and attribute defined as not null)

17
Q

VALUES clause

A

allows the addition of a single record based on the values it identifies
- can be replaced with a query to add multiple records

18
Q

attributes in VALUES clause

A

values specified in same order as attributes in INSERT clause
- have to provide a value for each value specified in INSERT clause

19
Q

UPDATE

A

changes the contents of one or more existing records in an existing table

20
Q

SET CLAUSE

A

can specify one or more attributes to be updated
can specify any valid value for the attribute whether specified explicitly, computationally, and/or as the result of a search

21
Q

DELETE

A

removes one or more existing records from a table

- with no where clause deletes everything