Lecture 9+10 Flashcards

1
Q

What are prime and non prime attributes?

A

Prime: a member of some candidate key
Nonprime: is not a member of any candidate key.

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

What are the main parts of normal forms?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we normalise to 1NF?

A

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.

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

What is a partial functional dependency?

A

A functional dependency which can lose some attribute from the LHS can be removed from the LHS and the dependency holds.

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

How do we normalise to 2NF?

A

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.

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

What is transitive dependency?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do we normalise to 3NF?

A

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.

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

What is BCNF?

A

whenever a nontrivial functional dependency holds in R the LHS is a superkey of R(remove functional dependencies that go backwards).

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

What is PL/SQL?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How is PL/SQL structured?

A

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).

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

What is the structure of an anonymous block?

A
[DECLARE 
... optional declaration statements ...]
BEGIN
...excutable statements
[EXCEPTION ... optional exception handler statements ...]
END;
/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are variables defined?

A

;
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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can we do loops in PL/SQL?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do user defined exceptions work?

A

Must be delcared in declarative part of PL/SQL block, and then raised explicitly using RAISE statement.

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

What is the syntax of a procedure?

A
CREATE [OR REPLACE] PROCEDURE name
IS|AS
 /* declaration section */
BEGIN
/* executable section - required */
[EXCEPTION
 /*Error handling statements
END [name];
/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What parameter modes can be specified for procedures?

A

IN(default) passes values to procedure being called, value vannot be changed inside procedure(constant).
OUT, return values to the caller of procedure, value can be changed or referenced in any way in procedure.
IN OUT pass initial values to procedure and return updated values to called, value can be changed inside procedure.

17
Q

How are functions different from procedures?

A

Functions have a RETURN clause after the CREATE section, detailing the datatype to return.

18
Q

What is a package?

A

A package collects a group of related procedures and functions.