Lecture 3 - SQL CREATE Flashcards

1
Q

What type of language is SQL?

A

a declarative language -> we say what rather than how

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

Statement for creating a schema in SQL?

A

CREATE SCHEMA name;

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

Each statement ends with a what in SQL?

A

;

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

SQL statement for creating a table?

A

CREATE TABLE name (attrs)

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

What do we need to specify when creating a table in SQL?

A

the name of the relation
attributes and their domain
any constraints

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

What domains can we have in SQL?

A

integer
real / decimal(digits , sig figs after decimal)
char(n)
varchar(n)
bit
bit varying
bool
date
timestamp
date intervals

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

Difference between char and varchar

A

Char allows exactly n characters while varchar allows from 0 to n characters

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

How do we put a PK constraint into CREATE TABLE?

A

At the end PRIMARY KEY (attr)

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

How do we put a FK constraint into CREATE TABLE?

A

At the end FOREIGN KEY (attr) REFERENCES TABLE(attr(s))

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

What value constrains are possible in SQL?

A
  • default value
  • NOT NULL
  • CHECK CLAUSE (checking if given value meets requirements and boundries)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the key constraint in SQL?

A

that the primary key is unique

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

What is an entity integrity constraint in SQL?

A

PK can’t be null

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

What is the UNIQUE clause?

A

specific candidate keys as they can uniquely identify a field

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

What are the triggered actions that are most common? (what happens on delete/update on relations with a referential constraint)

A

Action: ON DELETE SET NULL/ DEFAULT/ CASCADE
Action: ON UPDATE SET NULL/ DEFAULT /CASCADE

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

What is CASCADE?

A

propagate the change (DELETE/UPDATE) to referential relations

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