Relational Model Concepts

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Which of the following is NOT a requirement for a table to qualify as a relation?

  • Attributes (columns) must have unique names.
  • The order of the columns must be relevant. (correct)
  • All rows must be unique.
  • Every attribute value must be atomic.

In the context of database design, what do relations (tables) correspond to in the E-R model?

  • Entity instances
  • Attributes
  • Entity types and many-to-many relationship types (correct)
  • Constraints

Why are primary keys important in relational databases?

  • They can be simple or composite.
  • They enable a dependent relation to refer to its parent relation.
  • They speed up the response to user queries.
  • They guarantee that all rows in a relation are unique. (correct)

Which of the following scenarios demonstrates a violation of the entity integrity constraint?

<p>Inserting a row with a null value in a primary key field. (A)</p> Signup and view all the answers

What does referential integrity ensure in the context of relational databases?

<p>That a foreign key value has a matching primary key value in the related table. (D)</p> Signup and view all the answers

When transforming EER diagrams into relations, how are composite attributes handled?

<p>Only their simple, component attributes are used. (C)</p> Signup and view all the answers

When transforming EER diagrams into relations, what happens to multivalued attributes?

<p>They become a separate relation with a foreign key taken from the superior entity. (C)</p> Signup and view all the answers

When mapping a weak entity in an EER diagram to relations, what is the primary key of the new relation composed of?

<p>The partial identifier of the weak entity plus the primary key of the identifying relation. (C)</p> Signup and view all the answers

In the context of mapping binary relationships, how is a many-to-many relationship handled?

<p>A new relation is created with the primary keys of the two entities as its primary key. (B)</p> Signup and view all the answers

In a one-to-one binary relationship, if one side is mandatory and the other is optional, where does the primary key go as a foreign key?

<p>From the mandatory side to the optional side. (C)</p> Signup and view all the answers

What is the default primary key for an associative entity when an identifier is not assigned?

<p>The primary keys of the associated entities. (D)</p> Signup and view all the answers

In mapping unary relationships, what indicates a recursive foreign key?

<p>A foreign key that references the same table. (B)</p> Signup and view all the answers

When mapping ternary relationships, what attributes are included in the associative entity?

<p>Foreign keys to each entity in the relationship. (C)</p> Signup and view all the answers

When mapping supertype/subtype relationships, where do supertype attributes, including the subtype discriminator, go?

<p>Into the supertype table. (C)</p> Signup and view all the answers

What is the primary goal of data normalization?

<p>To minimize data redundancy and inconsistencies. (B)</p> Signup and view all the answers

A table should not pertain to more than one:

<p>Entity type (D)</p> Signup and view all the answers

What is a functional dependency in the context of database design?

<p>A relationship where the value of one attribute determines the value of another attribute. (C)</p> Signup and view all the answers

What is a candidate key?

<p>An attribute that can uniquely identify a row in a table. (A)</p> Signup and view all the answers

What is the problem with a relation that is not in First Normal Form (1NF)?

<p>It contains multivalued attributes. (C)</p> Signup and view all the answers

What condition must be met for a relation to be in Second Normal Form (2NF)?

<p>It must be in 1NF and every non-key attribute must be fully functionally dependent on the entire primary key. (B)</p> Signup and view all the answers

What is the key characteristic of a relation in Third Normal Form (3NF)?

<p>It exhibits no transitive dependencies. (C)</p> Signup and view all the answers

Which normal form is generally considered sufficient for most practical database designs?

<p>Third Normal Form (3NF) (A)</p> Signup and view all the answers

Among the issues with merging entities from different ER models, which describes attributes with the same name but different meanings?

<p>Homonyms (D)</p> Signup and view all the answers

What are enterprise keys and how do they relate to a database?

<p>Primary keys that are unique across the whole database, not just in a single relation. (A)</p> Signup and view all the answers

What does data manipulation refers to, within the components of the relational model?

<p>Powerful SQL operations for retrieving and modifying data. (B)</p> Signup and view all the answers

How are domain constraints enforced in a database?

<p>By defining allowable values for each attribute. (B)</p> Signup and view all the answers

Which of the following delete rules ensures that the 'parent' side cannot be deleted if related rows exist in the 'dependent' side?

<p>Restrict (A)</p> Signup and view all the answers

In database design, what does the term 'relation' refer to?

<p>A named, two-dimensional table of data. (D)</p> Signup and view all the answers

In the context of database normalization, which of the following describes the process of decomposing relations with anomalies to produce smaller, well-structured relations?

<p>Data normalization (D)</p> Signup and view all the answers

Which of the following constraints ensures that a foreign key value must match an existing primary key value in another table?

<p>Referential Integrity Constraint (A)</p> Signup and view all the answers

In the context of transforming EER diagrams to relational schemas, what is the impact of a multivalued attribute?

<p>It requires creating a new, separate relation (table). (C)</p> Signup and view all the answers

Which of the options below represents the correct transformation of a composite attribute from an EER diagram into a relational schema?

<p>Use only the simple, component attributes in the relation. (D)</p> Signup and view all the answers

When mapping a Many-to-Many binary relationship from an EER diagram to relations, why is a new relation created?

<p>All of the above. (D)</p> Signup and view all the answers

Which consideration is most important when deciding where to place a foreign key in a 1:1 binary relationship?

<p>Cardinality constraints and optionality. (D)</p> Signup and view all the answers

In the context of mapping associative entities, what is a key difference between an entity with an assigned identifier versus one without?

<p>Entities without identifiers use a composite key from related entities. (A)</p> Signup and view all the answers

In mapping unary relationships, what does a recursive foreign key accomplish?

<p>It establishes a hierarchy within the same table. (A)</p> Signup and view all the answers

When creating relations from a supertype/subtype structure, what does it mean to say that these are implemented as one-to-one relationships?

<p>All of the above. (D)</p> Signup and view all the answers

What is the main objective for View Integration when approaching relational databases?

<p>Combines entities from multiple E-R models into common relations. (B)</p> Signup and view all the answers

Which of the following describes transitive dependency, and how is it resolved?

<p>When a non-key attribute determines another non-key attribute; resolve by creating a new table. (A)</p> Signup and view all the answers

Which of the following is implemented with foreign key to primary references?

<p>Referential integrity constraints (B)</p> Signup and view all the answers

Signup and view all the answers

Flashcards

What is a relation?

Named, two-dimensional table of data with rows and columns.

What is a primary key?

A special field in a table that serves as a unique identifier. Guarantees all rows are unique.

What is a foreign key?

An identifier that enables a dependent relation to refer to its parent relation.

What are domain constraints?

Allowable values for an attribute.

Signup and view all the flashcards

What is entity integrity?

No primary key attribute may be null; primary key fields must have data.

Signup and view all the flashcards

Referential Integrity

Any foreign key value must match a primary key value in another relation. Or, the foreign key can be null.

Signup and view all the flashcards

What is Restrict (Delete Rules)?

Don't allow deletion of the 'parent' side if related rows exist in the 'dependent' side.

Signup and view all the flashcards

What is Cascade (Delete Rules)?

Automatically delete 'dependent' side rows that correspond with the 'parent' side row when it is deleted.

Signup and view all the flashcards

What is Set-to-Null (Delete rules)?

Set the foreign key in the dependent side to null if deleting from the parent side.

Signup and view all the flashcards

What are simple attributes?

E-R attributes maps directly onto the relation.

Signup and view all the flashcards

What are composite attributes?

Use only their simple, component attributes.

Signup and view all the flashcards

What is a multi-valued attribute?

Becomes a separate relation with a foreign key from the superior entity.

Signup and view all the flashcards

What is a One-to-Many binary relationship?

The primary key of the 'one' side becomes a foreign key on the 'many' side.

Signup and view all the flashcards

What is a Many-to-Many binary relationship?

Create a new relation, primary keys of the two entities as its primary key.

Signup and view all the flashcards

What is a One-to-One binary relationship?

Primary key on mandatory side becomes a foreign key on optional side.

Signup and view all the flashcards

Associative entity, Identifier Not Assigned

Primary key for the association is composed of the primary keys of the two entities.

Signup and view all the flashcards

Supertype/Subtype Relationships

One relation for supertype and for each subtype, supertype attributes go into the supertype relation. Subtype attributes go into each subtype.

Signup and view all the flashcards

What is Data Normalization?

Tool to validate and improve a logical design, avoid unnecessary data duplication.

Signup and view all the flashcards

What is Data Normalization?

Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data.

Signup and view all the flashcards

What is Insertion Anomaly?

Adding new rows forces the user to create duplicate data

Signup and view all the flashcards

What is Deletion Anomaly?

Deleting rows may cause a loss of data that would be needed for other future rows

Signup and view all the flashcards

What is Modification Anomaly?

Changing data in a row forces changes to other rows because of duplication.

Signup and view all the flashcards

General rule of thumb for table

A table should pertain to only one entity type.

Signup and view all the flashcards

What is Functional Dependency?

The value of one attribute (the determinant) determines the value of another attribute.

Signup and view all the flashcards

What is Candidate Key?

A unique identifier. A candidate key will become the primary key.

Signup and view all the flashcards

What is First Normal Form?

No multi-valued attributes.

Signup and view all the flashcards

What is Second Normal Form?

Every non-key attribute is fully functionally dependent on the entire primary key.

Signup and view all the flashcards

What is Third Normal Form?

no transitive dependencies

Signup and view all the flashcards

Functional Dependencies

The attributes on the one side determines attributes on the other side

Signup and view all the flashcards

Synonyms in merging

two or more attributes with different names but same meaning

Signup and view all the flashcards

Homonyms

attributes with same name but different meanings

Signup and view all the flashcards

Transitive Dependencies in merging

even if relations are in 3NF prior to merging, they may not be after merging

Signup and view all the flashcards

Supertype/subtype relationships in merging

may be hidden prior to merging

Signup and view all the flashcards

Enterprise Keys

Primary keys that are unique in the whole database, not just within a single relation

Signup and view all the flashcards

Study Notes

  • Tables consists of rows (records) and columns (attribute or field).

Components of the Relational Model

  • Data structure includes tables, rows, and columns.
  • Data manipulation can be performed with SQL operations for retrieving and modifying data.
  • Data integrity has mechanisms for implementing business rules that maintain integrity of manipulated data.

Relation Requirements

  • Relation is a named, two-dimensional table of data.
  • It must have a unique name.
  • Every attribute value must be atomic (not multivalued, not composite)
  • Every row must be unique
  • Attributes must have unique names
  • The order of the columns and rows must be irrelevant.
  • All relations are in first normal form.

Correspondence with E-R Model

  • Relations or tables in the relational model correspond with entity types and many-to-many relationship types in the E-R Model
  • Rows correspond with entity instances and many-to-many relationship instances
  • Columns correspond with attributes
  • The term "relation" in relational database is different from "relationship" in the E-R model.

Key Fields

  • Keys are special fields that serve two purposes.
  • Primary keys are unique identifiers of a relation, such as employee numbers or social security numbers.
  • Foreign keys enable a dependent relation to refer to its parent relation.
  • Keys can be simple or composite.
  • Keys are used as indexes to speed up query responses.

Integrity Constraints

  • Domain Constraints are allowable values for an attribute
  • Entity Integrity means no primary key attribute may be null, and all primary key fields must have data.
  • Action Assertions are business rules.

Referential Integrity

  • Referential Integrity states any foreign key value MUST match a primary key value.
  • For Delete Rules, there are three options:
    • Restrict: Don't allow delete of parent side if related rows exist in dependent side
    • Cascade: Automatically delete dependent side rows that correspond with the parent side row being deleted.
    • Set-to-Null: Set the foreign key in the dependent side to null if deleting from the parent side, but this is not allowed for weak entities.
  • Referential integrity constraints can be implemented using foreign keys referencing primary keys.

Mapping Regular Entities to Relations

  • Simple E-R attributes map directly onto the relation
  • Composite attributes utilize only their simple, component attributes.
  • Multivalued attributes create a separate relation with a foreign key taken from the superior entity.

Mapping Weak Entities to Relations

  • Weak entities become a separate relation with a foreign key from the superior entity.
  • The primary key is composed of a partial identifier of weak entity and the primary key of identifying relation (strong entity).

Mapping Binary Relationships to Relations

  • One-to-Many: The primary key on the one side becomes a foreign key on the many side
  • Many-to-Many: Creates a new relation with the primary keys of the two entities as its primary key
  • One-to-One: the primary key on the mandatory side becomes a foreign key on optional side.

Mapping Associative Entities to Relations

  • If the identifier is not assigned, the default primary key for the association relation consists of the primary keys of the two entities.
  • If the identifier is assigned it is natural and familiar to end-users, the default identifier may not be unique

Mapping Unary Relationships to Relations

  • One-to-Many relationships have a recursive foreign key in the same relation.
  • Many-to-Many relationships require two relations.
    • one relation for the entity type
    • one relation for an associative relation in which the primary key has two attributes taken from the primary key of the entity

Mapping Ternary Relationships

  • One relation for each entity, and one for the associative entity.
  • The associative entity has foreign keys to each entity in the relationship.

Mapping Supertype/Subtype Relationships

  • One relation for supertype and for each subtype.
  • Supertype attributes include identifier and subtype discriminator that go into the supertype relation.
  • Subtype attributes go into each subtype, the primary key of supertype relation becomes the primary key of subtype relation
  • 1:1 relationship established between supertype and each subtype, with supertype as primary table

Data Normalization

  • Data Normalization is a tool to validate and improve a logical design to satisfy constraints and avoid unnecessary data duplication.
  • It decomposes relations with anomalies to produce smaller, well-structured relations.

Well-Structured Relations

  • These contain minimal data redundancy and allow users to insert, delete, and update rows without inconsistencies.
  • Insertion Anomaly: Adding new rows forces the user to create duplicate data
  • Deletion Anomaly: Deleting rows may cause a loss of data that would be needed for future rows
  • Modification Anomaly: Changing data in a row forces changes to multiple rows because of duplication.
  • A table should not pertain to more than one entity type.

Functional Dependencies and Keys

  • Functional Dependency means the value of one attribute determines the value of another attribute
  • Candidate Key is a unique identifier, and one of the candidate keys will become the primary key.
  • Each non-key field is functionally dependent on every candidate key.

Normal Forms

  • First Normal Form: No multivalued attributes, and every attribute value is atomic. All relations are in 1st Normal Form.
  • Second Normal Form: Is 1NF with every non-key attribute fully functionally dependent on the entire primary key. Meaning every non-key attribute must be defined by the entire key, not just part of the key, also no partial functional dependencies.
  • Third Normal Form: Is 2NF with no transitive dependencies.
  • Generally, 3rd normal form is considered sufficient.

Merging Relations

  • This combines entities from multiple ER models into common relations
  • Watch out for the following issues:
    • Synonyms-two or more attributes with different names, but same meaning
    • Homonyms-attributes with the same name, but different meanings
    • Transitive dependencies-even if relations are in 3NF prior to merging, they may not be after merging
    • Supertype/subtype relationships-may be hidden prior to merging.

Enterprise Keys

  • Primary keys are unique in the whole database, not just within a single relation.
  • Corresponds with the concept of an object ID in object-oriented systems.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Relational Databases and SQL Quiz
5 questions
Relational Model Introduction
35 questions
Use Quizgecko on...
Browser
Browser