Week 4 Flashcards

1
Q

What are four basic SQL operations?

A

Create, Read, Update, and Delete (CRUD)

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

What does DDL stand for?

A

Data definition language - used to define, change, or drop database objects

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

What does DML stand for?

A

Data manipulation language - used to read and modify data

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

What does DCL stand for?

A

Data control language - used to grant and revoke authorizations

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

How can you create a table in SQL?

A

create table myTable (myColumn1 integer)

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

What are some 7 basic data types in SQL?

A

integer, float, decimal, char, date, time, blob

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

What does a UNIQUE constraint do?

A

A UNIQUE constraint prevents duplicate values in a table. This is implemented using unique indexes and is specified in the CREATE TABLE statement using the keyword UNIQUE. A NULL is part of the UNIQUE data values domain.

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

What does a PRIMARY KEY constraint do?

A

A PRIMARY KEY constraint is similar to a UNIQUE constraint, however, it excludes NULL as valid data. Primary keys always have an index associated with them. This defines a primary key for the table.

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

What does a REFERENTIAL constraint do?

A

A REFERENTIAL constraint is used to support referential integrity which allows you to manage relationships between tables.

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

What does a A CHECK constraint do?

A

A CHECK constraint ensures the values you enter into a column are within the rules specified in the constraint.

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

Can Referential integrity be defined during and after a table is created?

A

Referential integrity can be defined during table definition or after the table has been
created.

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

What is the name of a table whose column values depend on the values of other tables?

A

A table whose column values depend on the values of other tables is called a dependent, or
child table

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

What is a base or parent table?

A

A table being referenced by a child table or dependent.

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

When the constraint name is not specified what will happen in DB2?

A

The DB2 system will generate the name automatically

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

What are some delete action types?

A

A delete action type can be a CASCADE, SET NULL, NO ACTION, or RESTRICT.

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

What are some update action types?

A

An update action type can be a NO ACTION or RESTRICT.

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

What is a schema?

A

A schema in DB2 is a database object that allows you to group related database objects together

18
Q

How do you create a schema?

A

create schema mySchema

19
Q

What is a view?

A

A view is a virtual table derived from one or more tables or other views. It is virtual because
it does not contain any data, but a definition of a table based on the result of a SELECT
statement

20
Q

Can views be used for security?

A

Views allow you to hide data or limit access to a select number of columns; therefore, they
can also be used for security purposes.

21
Q

What does * represent?

A

All columns from a table

22
Q

what does SELECT do in SQL?

A

Selecting data in SQL is an operation that allows you to read (retrieve) rows and columns
from a relational table.

23
Q

What is a cursor in SQL?

A

A cursor is a resulting set from your selection

24
Q

What are the three things cursors can do in SQL?

A

Open (set/file/result), Fetch line by line, and Close (set/file/result)

25
Q

With INSERT can you insert one row, multiple rows per insert, or all rows of a query?

A

Yes, INSERT can be used one, many or all rows of a query

26
Q

With DELETE if you do not use a WHERE statement it will delete all rows from the table?

A

Yes, you need to use WHERE to avoid this like so - DELETE FROM myTable WHERE col1 > 1000

27
Q

With UPDATE if you do use a WHERE statement will it update all rows from the table?

A

Without a WHERE statement UPDATE will affect all rows

28
Q

What are table joins?

A

Ways that tables can be grouped together.

29
Q

What are the two types of table joins?

A

Inner Join (tables are equal or have matching names) and Outer Join (tables are joined in a particular direction left to right, both, right to left)

30
Q

Does the Union operator remove duplicate rows?

A

Yes, and the data sets must have the same column count in the same column definitions in the same order.

31
Q

What does the INTERSECT return?

A

INTERSECT returns common data between both sets

32
Q

What does the ALL keyword do?

A

It will allow duplicate data to show in Union, Intersect, Except

33
Q

What is the difference operator and what does it do?

A

The Except operator will return data that exists in A but not B, with no deplicates.

34
Q

What are 5 types of relational operators?

A

Basic mathematical operations like ‘+’, ‘-‘, ‘*’ and ‘/’
 Logical operators like ‘AND’, ‘OR’, and ‘NOT’
 String manipulation operators like ‘CONCATENATE’, ‘LENGTH’, ‘SUBSTRING’
 Comparative operators like ‘=’, ‘<’, ‘>’, ‘>=’, ‘<=’ and ‘!=’
 Grouping and aggregate operators
 Other miscellaneous operations like DISTINCT

35
Q

What do grouping operators do?

A

Perform operations on two or more rows (or columns) of data and provide a summary of the ouput

36
Q

What are aggregate operators?

A

Operators, which perform on two or more tuples or rows, and return a scalar result set, Like COUNT, SUM, AVERAGE, MINIMUM, etc

37
Q

What is a subquery?

A

When a query is applied within a query, the inner query is the subquery.

38
Q

Are subqueries executed first?

A

Yes, the result is then returned to the parent query.

39
Q

What are Scalar values?

A

Scalar values represent a single value of any attribute or entity, for example, Name, Age,
Course, Year, and so on

40
Q

What are vector values?

A

Vector values can be results returned from multiple data from a column or many columns

41
Q

What are the initials for the 5 keys?

A

 PRIMARY KEY: pk_
 UNIQUE: uq_
 DEFAULT: df_
 CHECK: ck_
 FOREIGN KEY: fk_