Exam 1.2 Flashcards

(24 cards)

1
Q

Order for SQL commands

A

Select
From
Where
Group By
Having
Order By

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

Types of datat in SQL

A

Varchar(size), Number, Integer, Char

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

How do integrity constraints work

A

-must apply to all instances of database
-defined when schema is modified
-checked when relations are modified

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

what is a superkey

A

A key that contains primary key and isn’t minimal

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

Ways of defining primary key x

A

X Primary Key [after it]
Primary key(x) [on seperate line]

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

What seperates data in tables and what ends them

A

commas and semicolons

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

what is entire table stored in

A

parenthesis

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

What happens if primary key isn’t defined

A

Database will define one on its own

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

Not null constraint

A

makes it so something cannot be null candidate keys and primary keys have this feature

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

How would a candidate key X be defined

A

using UNIQUE(X) keyword

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

how do foreign keys work

A

they are used to reference another item in a parent table

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

How would you make a foreign key x

A

FOREIGN KEY (x) references [other table] (parent id)

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

T or F can foreign keys be a tuple

A

True they can be a set they just must be unique

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

T or F foreign keys must have the same name as their parents

A

No foreigns keys can have any name

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

What are 3 ways to deal with deletes and preserving referential integrity

A

disallowing delete
cascade delete
set to default or null

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

What are the keywords for referential integrity

A

No action- does nothing
restrict - disallows deletion
cascade delete- deletes all things pointing to deleted
set null /set default

17
Q

How does drop table command work

A

drops table according to how the drop is specified could be drop tabl cascade

18
Q

What does drop table cascade constaints do

A

deletes entire table and foreign keys constaint is deleting reverting column back to what is was before

19
Q

How does alter tables work

A

Start with Alter table [tname]
and then what you want to do

20
Q

What are the different things that can be done with alter table

A

drop column
add column datatype
add key constraints ex ADD CONSTRAINT constraint_name FOREIGN KEY (column_name) REFERENCES parent_table(parent_column);

21
Q

How to insert into table

A

INSERT INTO table_name (column_name) VALUES (1234567890.99);

22
Q

How to use delete keyword

A

Same as a select but delete at the top instead

23
Q

How does update keyword work

A

has update, set, where

24
Q

how does Select statement work

A

has select from and where