Академический Документы
Профессиональный Документы
Культура Документы
A relation, say r1, may include among its attributes the primary key of
another relation, say r2. This attribute is called a foreign key from r1,
referencing r2. The relation r1 is also called the referencing relation of the
foreign key dependency, and r2 is called the referenced relation of the
foreign key
Participation constraint:
The participation of an entity set E in a relationship set R is said to be total if
every entity in E participates in at least one relationship in R. If only some
entities in E participate in relationships in R, the participation of entity set E
in relationship R is said to be partial. In Figure 7.5a, the participation of B in
the relationship set is total while the participation of A in the relationship set
is partial. In Figure 7.5b, the participation of both A and B in the relationship
set are total.
Normalization:
o Disable a Trigger
ALTER TABLE EMPLOYEE
DISABLE TRIGGER TRE_Em_History
o Disable a Trigger
Why Used: The trigger is mostly used for maintaining the integrity of the
information on the database. For example, when a new record (representing
a new worker) is added to the employees table, new records should also be
created in the tables of the taxes, vacations and salaries.
Derived attributes:
Derived attributes are those whose values are created from other attributes.
These values are generated with the help of algorithms, calculations and
other relevant procedures.
Example: In the entity Student, student Age would be considered a derived
attribute since it could be calculated using the student's date of birth with
the current date to find their age.
Schema
3A
o Because of the for each row clause the trigger will apply to each
row affected by the update statement.
for each row
The triggering statement will not only update the BOOKSHELF table,
but it reflects a lowering of the Rating value:
when (new.Rating < old.Rating)
The PL/SQL code shown in the following listing----- >is the trigger
body.
The commands shown here are to be executed for every update of
the BOOKSHELF table that passes through the when condition.
Therefor the BOOKSHELF_AUDIT table must exist, and the owner of
the trigger must have been granted privileges.
This example inserts the old values from the BOOKSHELF into the
BOOKSHELF_AUDIT table before the BOOKSHELF is updated.
/* begin
insert into BOOKSHELF_AUDIT
(Title, Publisher, CategoryName,
Old_Rating, New_Rating, Audit_Date)
values
(:old.Title, :old.Publisher, :old.CategoryName,
:old.Rating, :new.Rating, Sysdate);
end; */
4.B:
5. First, create a table that will store the audit records:
drop table BOOKSHELF_AUDIT;
create table BOOKSHELF_AUDIT
(Title VARCHAR2(100),
Publisher VARCHAR2(20),
CategoryName VARCHAR2(20),
Old_Rating VARCHAR2(2),
New_Rating VARCHAR2(2),
Audit_Date DATE);
In the first part of the trigger body the type of transaction is checked via an
if clause. Valid transaction types are INSERTING, and UPDATING.
The trigger checks whether to insert records into the BOOKSHELF table or
not. If it is, The INSERTING portion inserts the new values of the record into
the BOOKSHELF_AUDIT table. Otherwise update portion will execute
In this case, the attribute access_date which specifies when the customer
last accessed that account, could be associated with the account entity set.
Since each account entity participates in a relationship with at most one
instance of customer, which meaning the same if access_date is placed with
the depositor relationship set.
Attributes of a one-to-many relationship set can be repositioned only in the
many side of the relationship. For one-to-one relationship sets any one of
the participating entities can be repositioned.
4B.i
If there are five consecutive failed connection attempts to the JANE account,
the account will be automatically locked by Oracle. When you then use the
correct password for the JANE account, you will receive an error. Connect
jane/eyre
ERROR:
ORA-28000: the account is locked
To unlock the account, use the account unlock clause of the alter user
command (from a DBA account), as shown in the following listing:
alter user JANE account unlock;
Following the unlocking of the account, connections to the JANE account will
once again be allowed. You can manually lock an account via the account
lock clause of the alter user command.
alter user JANE account lock;
4b.ii
To prevent a password from being reused, you can use one of two profile
parameters: PASSWORD_REUSE_MAX or PASSWORD_REUSE_TIME. These
two parameters are mutually exclusive; if you set a value for one of them,
the other must be set to UNLIMITED.
The PASSWORD_REUSE_TIME parameter specifies the number of days that
must pass before a password can be reused. For example, if you set
PASSWORD_REUSE_TIME to 60, you cannot reuse the same password within
60 days.
The PASSWORD_REUSE_MAX parameter specifies the number of password
changes that must occur before a password can be reused. If you attempt to
reuse the password before the limit is reached, Oracle will reject your
password change.
There are two types of weak entities: associative and subtype entities.
View
View is a query () used as a
table which can be linked to another
table.
Views are "imaginary" tables that
are constructed based on the actual
tables.
We can have
a table without having a views.
Table does not provide security
Table takes more space than view
Table is little complex than view as
it is a list of all records.
Trigger:
Types of Triggers:
Triggers can be categorized according to their means of invocation and the
type of actions they perform. Oracle Database supports the following types
of triggers:
1. Row triggers
A row trigger fires each time when the table is affected by the triggering
statement. For example, if a statement updates multiple rows, then a row
trigger fires once for each row affected by the UPDATE. If a triggering
statement affects no rows, then a row trigger is not run.
Row triggers are useful if the code in the trigger action depends on the data
provided by the triggering statement or the rows affected.
2. Statement triggers
A statement trigger is fired once on behalf of the triggering statement,
regardless of the number of rows affected by the triggering statement. For
example, if a statement deletes 100 rows from a table, a statementlevel DELETE trigger is fired only once.
Statement triggers are useful if the code in the trigger action does not
depend on the data provided by the triggering statement or the rows
affected.
3. Instead OF triggers
An INSTEAD OF trigger is fired by Database instead of executing the
triggering statement key.
These triggers are useful for transparently (clearly) modifying views that
cannot be modified directly through DML statements.
4. Event triggers
Event triggers can be used to publish information about database events to
subscribers. Event triggers are divided into the following categories:
o A system event trigger can be caused by database instance startup
and shutdown or error messages etc.
o A user event trigger is fired because of events related to user logon
and logoff, DDL statements, and DML statements.
Advantages:
1.
2.
3.
4.
5.
6.
7.
Super key
A super key is a combination of columns that uniquely identifies any row
within a relational database management system table.
For example, imagine a table used to store customer master details that
contains columns such as:
Customer name
Customer ID
Social security number (SSN)
Address
Date of birth
E-R Diagram:
Definition: a graphical representation of entities and their relationships to
each other
The elements of an ERD are:
Entities
Relationships
Attributes
Data mining
Data Mining is the process of extracting knowledge hidden from large
volumes of raw data. The knowledge must be new, not obvious, and one
must be able to use it.
There are two main kinds of models in data mining. One is predictive
models, which use data with known results to develop a model that can be
used to explicitly predict values. Another is descriptive models, which
describe patterns in existing data
An Oracle role is a set of privileges (or the type of access that each user
needs, depending on his or her status and responsibilities).
Database object privileges give you the ability to perform some operation on
various objects.The DELETE privilege, for example, lets you delete rows from
tables and views.
Rollback:
We can perform a large number of insert, update, and delete operations and
still undo the work (return the tables to the way they used to be) by issuing
this command
rollback;
rollback complete
The Oracle can rolled back any work that hasnt been committed.
The process of committing or rolling back work is controlled by two SQL*Plus
commands: commit and rollback.
Delete
Removing a row or rows from a table requires the delete command. The
following command deletes the Walpole entries from the COMFORT
table:
delete from COMFORT where City = 'WALPOLE';
o recovery is possible, so long as a commit hasnt occurred using rollback
o An additional command for deleting records, truncate, does not behave
the same as delete
o Whereas delete allows you to commit or roll back the deletion