Lecture 9+10 Flashcards
What are prime and non prime attributes?
Prime: a member of some candidate key
Nonprime: is not a member of any candidate key.
What are the main parts of normal forms?
1NF: all attribute values are atomic.
2NF: 1NF and every non-key attribute is fully dependend on the primary key.
3NF: 2NF and every non-key attribute is non-transitively dependent on primary key.
BCNF: Every LHS of a functional dependency is a candidate key.
4NF: No multivalued dependencies
5NF: Every join dependency is a consequence of candidate keys.
How do we normalise to 1NF?
Remove multivalued or composite attribute and create a new relation for it. Add a copy of primary key of original relation and then determine primary key of new relation.
What is a partial functional dependency?
A functional dependency which can lose some attribute from the LHS can be removed from the LHS and the dependency holds.
How do we normalise to 2NF?
Remove nonprime attributes that are only partially functional dependent on primary key, place them in a new relation, this relation should contain the determinants of the non prime attributes and become the primary key.
What is transitive dependency?
A functional dependency is transitive if there are a set of attributes in the relation that are neither a candidate key or a subset of a key of the relation and the LHS of the functional dependency can determine these, and these attributes can determine the RHS of the functional dependency.
How do we normalise to 3NF?
Remove nonprime attributes which are transitively dependent on the key attributes, and place in a new relation.
Add a copy of the determinant attributes of these attributes, which will become the primary key of this new relation.
What is BCNF?
whenever a nontrivial functional dependency holds in R the LHS is a superkey of R(remove functional dependencies that go backwards).
What is PL/SQL?
Adds programming capabilities to SQL, adding control structures, data abstraction, information hiding, exception handling, enforcement of complex constraints, and allowing subprograms to be stored in the database to allow for storage in executable form for better performance.
How is PL/SQL structured?
Into blocks, each of which generally corresponds to a problem or subproblem.
Anonymous blocks are program units with no name, they are compiled each time they are executed.
Stored subprograms are named units, each is compiled separately and permanently in an oracle database, they can be procedures(no return value), or functions(return a value).
What is the structure of an anonymous block?
[DECLARE ... optional declaration statements ...] BEGIN ...excutable statements [EXCEPTION ... optional exception handler statements ...] END; /
How are variables defined?
;
variables can have attributes, with a % sign denoting an attribute, with .%TYPE giving the datatype from the table and %ROWTYPE provides a record type representing a row in the table.
How can we do loops in PL/SQL?
simple loops using LOOP and using EXIT and END LOOP at end(or EXIT WHEN ).
A while loop using WHILE LOOP and ending with END LOOP;
A FOR loop using FOR counter in lower..uppper LOOP
ending with END LOOP.
A CURSOR for loop is one actually defined by an explicit cursor.
How do user defined exceptions work?
Must be delcared in declarative part of PL/SQL block, and then raised explicitly using RAISE statement.
What is the syntax of a procedure?
CREATE [OR REPLACE] PROCEDURE name IS|AS /* declaration section */ BEGIN /* executable section - required */ [EXCEPTION /*Error handling statements END [name]; /