Lecture Materials Week 9 (File Name) Flashcards

(36 cards)

1
Q

SQL stands for

A

Structured Query Language

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

SQL was developed by this company in the late 70s

A

IBM

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

SQL is not a full-featured ___________ ________

A

programming language

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

SQL is a ____ ___________ for creating and processing database data/metadata

A

data sublanguage

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

SQL statements can be divided into 5 categories, they are:

A

DDL: Data definition language

DML: Data manipulation language

DCL: Data control language

TCL: Transaction control language

and SQL/PSM: Persistent stored modules statements

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

The ______ _____ statement is used to create relations

A

CREATE TABLE

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

Each column in a table is described with 3 parts:

A

Column name, data type, and optional constraints

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

Place these in the correct order

DataType
ColumnName
OptionalConstraint

A

ColumnName Datatype Optional Constraint

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

Place these in the correct order

Optional table constraint

CREATE TABLE newTableName

ColumnName DataType OptionalConstraint,

A

CREATE TABLE newTableName

ColumnName DataType Optional Constraint,

Optional table constraint

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

Constraints can be ______ __ the CREATE TABLE statement or can be added _____ using the _____ table statement

A

placed in, added after, ALTER Table

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

5 Different Column/table constraints

A

Primary key
Foreign key
NULL/NOT NULL
Unique
Check

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

The _______ keyword can be used to set initial values

A

Default

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

Implementing Cardinalities:

1:N relationship, parent optional

A

Set foreign key to NULL.

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

Implementing Cardinalities:

1:N relationship, parent required

A

Set foreign key to NOT NULL.

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

Implementing Cardinalities:

1:1 relationship, parent optional

A

Specify a foreign key UNIQUE constraint. Set foreign key to NULL.

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

Implementing Cardinalities:

1:1 relationship, parent required:

A

Specify foreign key UNIQUE constraint. Set foreign
key NOT NULL.

17
Q

Casual relationship

A

Create a foreign key column, but do not
specify FOREIGN KEY constraint. If
relationship is 1:1, specify a foreign key
UNIQUE constraint.

18
Q

You are making the attribute “WorkID” a primary key in the “Work” table, what would the statement be to create it?

A

CONSTRAINT WorkPK PRIMARY KEY( WorkdID )

19
Q

You are making the “Title” and “Copy” attributes a unique key in the “Work” table, what would the statement be to do this?

A

CONSTRAINT WorkUK1 UNIQUE( Title, Copy )

20
Q

You are making “ManufacturerID” a foreign key in the “Work” table, it will be referencing the “Manufacturer” table. What is the statement to do this?

A

CONSTRAINT ManfacturerFK FOREIGN KEY( ManfacturerID )
REFERENCES Manufacturer( ManufacturerID )

21
Q

The SQL ALTER TABLE statement is used to

A

Change the structure of an existing table.

22
Q

The ALTER TABLE statement can not only add, remove or change columns, but can also

A

add or remove constraints

23
Q

ALTER TABLE statement that will add a column named MyColumn to the Customer table - Char(5), NULL

A

ALTER TABLE Customer
ADD myColumn Char(5) NULL:

24
Q

ALTER TABLE statement that will drop MyColumn from the customer table

A

ALTER TABLE Customer
DROP COLUMN MyColumn;

25
ALTER TABLE statement that will add myConstraint that will check that a customers LastName is not in the AddressBook
ALTER TABLE CUSTOMER ADD CONSTRAINT myConstraint CHECK ( LastName NOT IN ( AddressBook )
26
ALTER TABLE statement that will drop myConstraint from the customer table
ALTER TABLE CUSTOMER Drop Constraint myConstraint;
27
Put this in order to change the last_name column to surname in the student table student RENAME COLUMN surname ALTER TABLE last_name TO
ALTER TABLE student RENAME COLUMN last_name TO surname;
28
Truncate table
Removes all data from a table while leaving the structure intact - Can't be used with a table that is references by a foreign key in another table
29
An _____ is a special data structure that is created to improve database performance
Index
30
3 types of index statements
CREATE, ALTER, DROP
31
To speed up inserting data you can use a ____ ______ statement to insert entire imports
Bulk INSERT
32
If you do not include a WHERE statement in an update
A bulk update will execute and change every row in the entire table
33
UPDATE CUSTOMER SET AreaCode = '303' WHERE City = 'Denver' Explain how this results in a bulk update, despite the included WHERE statement
All AreaCodes in Denver will be set to 303
34
The SQL MERGE statement combines the ______ and ______ statements into one, and will do one or other depending on conditions
INSERT, UPDATE
35
If you omit the WHERE clause from the DELETE statement
You will delete every row in the table
36
T/F - The SQL DELETE statement resets surrogate key values
False