databases Flashcards
(230 cards)
What is an entity set?
- set of entities of the same type sharing the same set of attributes
What is a relationship set?
- set of relationships between one or many entity sets
- an attribute can also be a property of a relationship set
What is an n-ary relationship?
- involving n entity sets
- relationships involving more than two entity sets (binary relationship)
What are the multiplicity constraints?
- participation
- cardinality
What is participation?
- determines if an entity is require or just allowed to be part of a relationship
- total: represented with a double line
- partial: represented with a single line
What is cardinality?
- the maximum amount an entity can take part in a relationship set
- one to one
- one to many
- many to one
- many to many
- a directed line (arrow) represents “one”
- an undirected line represents “many”
What is a candidate key?
- minimal set of attributes that uniquely identifies each entity in an entity set
- primary key is the candidate key chosen to uniquely identify each entity
What is a weak entity set?
- an entity set with no candidate keys
- relies on a strong or identifying entity set for context and meaning
- have total participation with identifying sets
- represented with a double lined diamond
- one to many relationship from each identifying set to the weak entity set
primary key is the identifying set with the weak set’s discriminator
What is a discriminator (aka a partial key)?
- set of attributes that distinguishes among all the entities of a weak entity set
What shape is used to represent an entity set?
- rectangles
- divided in two parts
What is used to indicate a primary key in an ER diagram?
- underlining
What shape is used to represent a relationship set?
- diamonds
How is a composite attribute represented?
-indentation
How is a derived attribute represented?
- the derived attribute is followed by parentheses()
How is a multi-valued represented?
- {enclosed in braces}
What is generalisation (also called specialisation)?
- referred to as superclass-subclass relationship or inheritance
- lower level entity set inherits all the attributes and relationship participation of the higher level entity set to which it is linked
What are the inheritance constraints?
- total: entity must belong to one of the subclass entity sets. Represented with a keyword total.
- partial: entity need not belong to one of the subclass entity sets. Default unless total is specified.
- overlapping: an entity can only belong to more than one subclass entity set (multiple arrows to the superclass)
- disjoint: an entity can belong to at most one subclass entity set (single arrow to the superclass, line splits to subclass)
Is an attribute better placed on an entity set or a relationship set?
– An attribute of a many-to-many relationship set must be placed on the relationship set
– An attribute of a one-to-many relationship set can be placed on the relationship set or the many-side entity set
– An attribute of a one-to-one relationship set can be placed on the relationship set or in either entity set
– An attribute of a many-to-many relationship set must be placed on the relationship set
How do you change a weak entity set to a strong entity set?
- adding an artificial key
When to use inheritance or not?
- If entities share attributes there may or may not be a specialisation/generalisation relationship
What is the simple modelling methodology?
- Identify entity sets
– Use nouns to determine what needs representation, discarding inappropriate candidates. - Define attributes
– Establish primary keys, other stored information, and any derived attributes. - Determine relationships
– Use verbs or entity names, considering cardinality and participation. - Assess generalisation/specialisation
– Apply if it reduces redundancy or makes logical sense.
What is required of attributes?
To be atomic.
What is the set of allowed values for each attribute?
The domain.
What is a relation schema and how does it relate to attributes and domains?
- Attributes ({A1, A2, …, An}): Names of properties in a database.
- Domains ({D1, D2, …, Dn}): Defines possible values for each attribute.
- Relation Schema (R = (A1, A2, …, An)): A template of a table consisting of attributes.
- Relation: A set of n-tuples, where each tuple is an ordered list of n values (a1, a2, …, an) forming a row.
- Each value ai must be an element of domain Di, corresponding to attribute Ai.