Week 6 Flashcards
What does date store?
A 4 digit year, month and date
What does time store?
Time of day in hours, minutes and seconds
What does datetime store?
The date plus the time of day
What is the difference between datetime and timestamp?
Timestamp has timezones
Why would you choose to create a domain over a type?
Easier to have constraints and default values compared to types
Why would you create indexes?
Helps to speed up searches
What do indexes slow down?
Insert, update and delete operations
What is the syntax for creating an index?
CREATE INDEX index_name ON table_name (A1, A2,…)
What is the motivation for creation of views?
So that not all users have to see the entire logical model of a database
Describe a view
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
What is the syntax for creating a view?
create view v as
Why do most SQL implemenations only let you update simple views?
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
What conditions have to hold for a view to be updatable?
<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>
What is a materialized view?
Computes and stores results at the time of creation
What are the 5 forms of authorisation on the databse?
<ol> <li>Select</li> <li>Insert</li> <li>Update</li> <li>Delete</li> <li>Execute</li> </ol>
What are the 3 forms of authorisation on the database schema?
<ol> <li>Create</li> <li>Alter</li> <li>Drop</li> </ol>
What does select authorisation give?
Allows reading but not modification of data
What does insert authorisation give?
Allows insertion of new data but not modification of existing data