Week 6 Flashcards

1
Q

What does date store?

A

A 4 digit year, month and date

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

What does time store?

A

Time of day in hours, minutes and seconds

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

What does datetime store?

A

The date plus the time of day

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

What is the difference between datetime and timestamp?

A

Timestamp has timezones

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

Why would you choose to create a domain over a type?

A

Easier to have constraints and default values compared to types

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

Why would you create indexes?

A

Helps to speed up searches

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

What do indexes slow down?

A

Insert, update and delete operations

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

What is the syntax for creating an index?

A

CREATE INDEX index_name ON table_name (A1, A2,…)

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

What is the motivation for creation of views?

A

So that not all users have to see the entire logical model of a database

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

Describe a view

A

A “virtual relation” that conceptually contains the results of a query, but in reality the query is re-executed each time the view is called

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

What is the syntax for creating a view?

A

create view v as

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

Why do most SQL implemenations only let you update simple views?

A

Updates can’t be translated uniquely and we end up with ambiguity about what other updates need to take place in the database

Can allow for items to go into view where the where clause for original view doesn’t hold

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

What conditions have to hold for a view to be updatable?

A

<ul>
<li>The from only has one table</li>
<li>The select only has attributes names of the relation, no expressions, aggregates or distinct specifications</li>
<li>Any attribute not listed in the select clause can be set to null</li>
<li>The query does not have a group by or having clause</li>
</ul>

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

What is a materialized view?

A

Computes and stores results at the time of creation

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

What are the 5 forms of authorisation on the databse?

A
<ol>
<li>Select</li>
<li>Insert</li>
<li>Update</li>
<li>Delete</li>
<li>Execute</li>
</ol>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the 3 forms of authorisation on the database schema?

A
<ol>
<li>Create</li>
<li>Alter</li>
<li>Drop</li>
</ol>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does select authorisation give?

A

Allows reading but not modification of data

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

What does insert authorisation give?

A

Allows insertion of new data but not modification of existing data

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

What does update authorisation give?

A

Allows modification, but not insertion or deletion of data

20
Q

What does delete authorisation give?

A

Allows deletion of data

21
Q

What does execute authorisation give?

A

Allows execution of stored procedures

22
Q

What does create authorisation give?

A

Allows creation of tables/database

23
Q

What does alter authorisation give?

A

Allows addition or deletion of attributes in a relation

24
Q

What does drop authorisation give?

A

Allows deletion of tables/databases

25
Q

What is the syntax for the grant statement?

A

grant X on Y to Z

26
Q

What does the with grant option do?

A

Allow a user who is granted a privilege to pass the privilege on to other users

27
Q

Who is at the root of the authorisation graph?

A

The database administrator (DBA)

28
Q

What does restrict option mean for when a privilege is revoked?

A

Only the person stated privilege is revoked

29
Q

What does the cascade option mean for when a privilege is revoked?

A

Everything the person to be revoked has granted is revoked

30
Q

What is the Authorisation Grant Graph requirement?

A

All edges in an authorisation graph must be part of some path originating with the database administrator

31
Q

How would you grant select access at global level?

A

grant select on . to ‘user’@’%’

32
Q

What is the main limitation of SQL authorisation?

A

Cannot grant privileges at the row level within the database directly

33
Q

How can row level authorisation be provided to users?

A
<ul>
<li>Application program that accesses database</li>
<li>Views</li>
<li>Procedures</li>
</ul>
34
Q

What can be combined in order to ensure users can only access precisely the data that the user needs?

A

<ul>
<li>Relational level security</li>
<li>View level security</li>
</ul>

35
Q

How do you do power in SQL?

A

pow(x,y)

x to the power of y

36
Q

How many values can a function return in SQL?

A

One

37
Q

What is the minimum number of values a function can return?

A

One

38
Q

What is the minimum number of values a procedure can return?

A

Zero

39
Q

How are functions and procedures related?

A

A function can always be a procedure, a procedure can’t always be a function

40
Q

Where can procedures be invoked?

A

From an SQL procedure or from programs, but not within a select query

41
Q

What would you use if you want to return the execution of an entire query?

A

Procedure

42
Q

What is a trigger?

A

Statement that is executed automatically by the system as a side effect of a modification to the database

43
Q

What must be specified when designing a trigger?

A

<ul>
<li>Conditions under which the trigger is executed</li>
<li>Actions to be taken when the trigger executes</li>
</ul>

44
Q

What is the basic trigger syntax?

A

CREATE TRIGGER {BEFORE | AFTER} ON FOR EACH ROW

45
Q

What can the events be in a trigger?

A
<ul>
<li>Insert</li>
<li>Delete</li>
<li>Update</li>
</ul>
46
Q

What can the action be in a trigger?

A

<ul>
<li>Single SQL update/insert/delete statement</li>
<li>Multiple statements within the BEGIN .... END construct </li>
</ul>