Professional Documents
Culture Documents
CHP 4
A view is updatable when?
Any attribute not listed in the select clause can be set to null; that is, it does
not
have a not null constraint and is not part of a primary key.
The query does not have a group by or having clause.
view relation
View relations can be defined as relations containing the result of queries.
Views
are useful for hiding unneeded information and for gathering together
information
from more than one relation into a single view.
integrity constraint
Integrity constraints ensure that changes made to the database by authorized
users
do not result in a loss of data consistency.
domain constraint
Domain constraints specify the set of possible values that may be associated
with
an attribute. Such constraints may also prohibit the use of null values for
Chp4 1
particular
attributes.
Transaction
Transactions are sequences of queries and updates that together carry out a
task.
Transactions can be committed, or rolled back; when a transaction is rolled
back,
the effects of all updates performed by the transaction are undone.
Assertion
Assertion example
Indices
Chp4 2
Indices are important for efficient processing of queries, as well as for
efficient
enforcement of integrity constraints. Although not part of the SQL standard,
SQL
commands for creation of indices are supported by most database systems.
Roles
Roles enable us to assign a set of privileges to a user according to the role
that the
user plays in the organization.
Dropping constraint
creating index
creating domain
auto increment
we use auto increment in place of generated always as identity, while in SQL
Server we can use just identity.
reference privilege
Chp4 3
SQL includes a references privilege that permits a user to declare foreign
keys when creating relations.
grant references (dept name) on department to Mariano;
authorization graph
The passing of a specific authorization from one user to another can be
represented by an authorization graph.
The nodes of this graph are the users.
A user who creates a new relation is given all privileges on that relation
automatically.
Authorizations on data include:
Authorization to read data. Authorization to insert new data.
Authorization to update data. Authorization to delete data.
Each of these types of authorizations is called a privilege.
final
That's correct. If you create a user-defined data type in SQL and mark it
as "FINAL", you cannot extend or modify that data type to create new
subtypes. This means that you cannot convert the "Dollars" type to a
different data type later, or create new data types based on the "Dollars"
type.
Chp4 4
If you need to modify the data type later, you will need to create a new
data type based on the original "Dollars" type, but with the modifications
you require. This new data type would not be considered a subtype of the
"Dollars" type, but rather a separate data type that shares some of the
same characteristics.
It's worth noting that marking a data type as "FINAL" can help to ensure
data integrity and consistency in a database system, but it can also limit
flexibility and make it more difficult to modify the data type later. It's
important to consider the trade-offs carefully when designing a database
schema and deciding how to define user-defined data types.
extract function
In SQL, the EXTRACT function is used to extract a specific part (such as
year, month, day, hour, minute, or second) of a date or timestamp value.
Here's an example of how to use the EXTRACT function in a SQL query:
sys-context→private data
Chp4 5
level authorization to ensure that each bank teller can only access the
account information for the customers they are assigned to serve.
Row-level authorization can be implemented in different ways, depending on
the database system being used. Some databases provide built-in row-level
security features, while others may require the use of custom scripts or third-
party tools to implement this type of security. Regardless of the
implementation, row-level authorization is an important tool for ensuring the
security and integrity of sensitive data stored in a database.
decode example
select ID, decode (salary, null, 'N/A', salary) as salary
from instructor
lob
clob, blob
grant eg
grant <privilege list> on <relation name or view name> to <user/role list>;
grant select on department to Amit, Satoshi;
grant update (budget) on department to Amit, Satoshi;
revoke eg
cascading revocation
Chp4 6
with the "RESTRICT" option, the revocation will only be allowed if the
privilege is not currently in use by any of the specified users or roles.
For example, if "Amit" and "Satoshi" were both granted the "SELECT"
privilege on the "department" table, and then other users were granted the
"SELECT" privilege on views or subqueries based on the "department" table,
those dependent privileges would also be automatically revoked if the original
"SELECT" privilege is revoked with the "CASCADE" option.
Using the "CASCADE" option can help to ensure that dependent privileges
are not left dangling or unused when the original privilege is revoked, and
can help to maintain data integrity and security in a database system.
However, it's important to use this option carefully and ensure that all
dependent privileges are correctly identified and accounted for before
revoking the original privilege.
Chp4 7
like ‘ab#%cd%` escape # ;v
inner→correlated
transaction
commit work
rollback work
atomic→indivisible
dependencies→type of constraints
Chp4 8