Exam Flashcards
RELATIONSHIP TABLES
in a 1 to many relationship what do we do with the entities and the relationship?
combine the the 1 with the relationship (i.e. the one with the arrow)
RELATIONSHIP TABLES
how are participation constraints manifested as in tables?
by not nulls
RELATIONSHIP TABLES
how are key/cardinality constraints manifested?
by foreign keys
RELATIONSHIP TABLES
how are binary relationships manifested?
their own table with a composite primary key that reflects the two different types of relationships they describe
EX. reports_to has supervisor/subordinate so the primary key is supervisor_ssn,subordinate_ssn which are foreign keys of the parent entity
RELATIONSHIP TABLES
how are weak entities displayed?
a weak entity combines the entity with the relationship it is defined by and then uses a partial key composed of its local key and the primary key of the connected entity(s) (also ON DELETE CASCADE/UPDATE)
RELATIONSHIP TABLES
if an entity has a participation constraint does it always require its own table?
not always
ER DIAGRAMS
“must participate”
this means a participation constraint or a thick line connecting the two elements
ER DIAGRAMS
“X is related to NO MORE than ONE Y”
key constraint - draw an arrow pointing to Y from X
ER DIAGRAMS
what is a cardinality constraint?
look for arrows and their can only be one of those elements in a relationship between them
ER DIAGRAMS
what is a participation constraint?
look for thick lines. entities connected must be paired as tuples at all times
ER DIAGRAMS
thick line
> 1
ER DIAGRAMS
arrow
< 1
FDs/NORMAL FORMS
define 3NF
where all FDs have either the superkey on the LHS OR their RHS is part of the superkey
FDs/NORMAL FORMS
How do we synthesize 3NF?
1) reduce to single attribute RHS
2) check LHS to see if every attribute is actually necessary for the FD
3) remove redundant rules (check closures to see/remove repeats)
4) take completed FDs and write out as R1(xy) R2(yz)…
FDs/NORMAL FORMS
define BCNF
where all FDs are strictly have the superkey on the LHS
FDs/NORMAL FORMS
how do we decompose to BCNF?
1) check which FDs are not in BCNF and decompose on the ones which are not
2) Decompose R into two subschemas, one with the offending FD attributes, the other with the original minus the offending
3) now check those subschemas as if they were their own relations, and iterate over and over until both satisfy BCNF
RA/DATALOG
What is division used for?
“find all of that have RESERVED ALL BOATS” for example
SQL
what does WHERE IN do?
It looks for the given attribute in the results of the subquery.
ex. “Find the who did X”
SQL
WHERE EXISTS does what?
Checks whether a given set is empty or not
“Find the blank of blanks who have done x”
SQL
ANY does what?
finds a random example of the subquery that follows it
SQL
ALL does what?
finds every example of the subquery that follows it
SQL
WHERE NOT EXISTS does what?
returns true if the subquery doesn’t satisfy the result
SQL
COUNT ((DISTINCT) A) does what?
the number of values in column A
SQL
GROUP BY
Collects the query results by the given attribute