Relational Model: Data Structure, Manipulation

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What are the three main components of the relational model?

  • Data warehousing, Data mining, Data analysis
  • Data definition, Data querying, Data security
  • Data structure, Data manipulation, Data integrity (correct)
  • Data types, Data constraints, Data validation

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

  • The order of the columns must be relevant. (correct)
  • Every row must be unique.
  • Every attribute value must be atomic.
  • It must have a unique name.

In the context of relational databases and E-R models, which statement is correct?

  • The term 'relation' is synonymous with 'relationship' in E-R models.
  • Columns in a relation correspond with entity instances.
  • Relations correspond to entity types and many-to-many relationship types. (correct)
  • Rows in a relation correspond with attributes in an E-R model.

What is the primary purpose of a foreign key?

<p>To enable a dependent relation to refer to its parent relation. (D)</p> Signup and view all the answers

Which type of integrity constraint defines the allowable values for an attribute?

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

What does the referential integrity constraint ensure?

<p>A foreign key value must match a primary key value in another relation or be null. (A)</p> Signup and view all the answers

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

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

In the context of mapping weak entities, what constitutes the primary key of the new relation?

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

When mapping a one-to-many binary relationship, what happens to the primary key of the 'one' side?

<p>It becomes a foreign key in the 'many' side relation. (B)</p> Signup and view all the answers

In mapping a many-to-many binary relationship, what is created?

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

For a one-to-one binary relationship, where does the primary key of the mandatory side go?

<p>It becomes a foreign key on the optional side. (D)</p> Signup and view all the answers

What is the default primary key for the association relation when mapping associative entities without an assigned identifier?

<p>The combination of the primary keys of the two entities involved in the association. (D)</p> Signup and view all the answers

In transforming unary relationships, what is used to represent a one-to-many relationship?

<p>A recursive foreign key in the same relation. (C)</p> Signup and view all the answers

In the context of transforming EER diagrams into relations, how are ternary relationships handled?

<p>One relation for each entity and one for the associative entity. (A)</p> Signup and view all the answers

When mapping supertype/subtype relationships, what happens to the supertype attributes?

<p>They go into the supertype relation. (D)</p> Signup and view all the answers

What is the primary goal of data normalization?

<p>To validate and improve a logical design, avoiding unnecessary duplication of data. (A)</p> Signup and view all the answers

Which of the following describes an insertion anomaly?

<p>Adding a new row forces the user to create duplicate data. (B)</p> Signup and view all the answers

Which normal form is generally considered sufficient in most practical database design scenarios?

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

What does a functional dependency describe?

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

Which of the following conditions defines First Normal Form (1NF)?

<p>No multivalued attributes and every attribute value is atomic. (D)</p> Signup and view all the answers

What is the key requirement for a relation to be in Second Normal Form (2NF)?

<p>It must be in 1NF and have no partial functional dependencies. (D)</p> Signup and view all the answers

What must be eliminated for a table to satisfy Third Normal Form (3NF)?

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

What are 'synonyms' to watch out for when merging entities from different ER models?

<p>Attributes with different name but same meanings (C)</p> Signup and view all the answers

Among the issues that should be considered when merging entities from different E-R models, which one describes attributes that have the same name but different meanings?

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

What is the definition of enterprise keys?

<p>A special kind of primary key that are unique in the whole database (B)</p> Signup and view all the answers

How are composite attributes handled when transforming EER diagrams into relations?

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

Consider a scenario where deleting a row from a table causes the loss of related but necessary information. Which type of anomaly is this an example of?

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

When transforming a many-to-many unary relationship, what is the resulting structure?

<p>Two relations: one for the entity type and one for an associative relation. (A)</p> Signup and view all the answers

Which of the following is true about subtypes?

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

What is the purpose of analyzing functional dependencies?

<p>To normalize relations (C)</p> Signup and view all the answers

What are the attributes in a table in 2NF?

<p>Dependent on only the primary key (D)</p> Signup and view all the answers

Consider EMPLOYEE (Name, Address, Salary, SSN, EmpID, DeptName). If an employee changes department, all employee data must be re-entered. This is an example of?

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

For each of the normal forms, which one could have transitive dependencies?

<p>2NF (B)</p> Signup and view all the answers

What happens when removing partial dependencies?

<p>Partial dependencies are avoided, but transitive dependencies could still exist (A)</p> Signup and view all the answers

To be well-structured, a table ideally should have the following properties:

<p>Minimal redundancy and allow insert, delete, and update without inconsistencies (B)</p> Signup and view all the answers

Which of the following is true about keys?

<p>Primary keys guarantee that all rows are unique (A)</p> Signup and view all the answers

What is the referential integrity constraint rule if deleting from the parent side?

<p>Restrict-don't allow delete of 'parent' side if related to ‘dependent’ table (D)</p> Signup and view all the answers

Using SQL Data Definition Language, how would you set it so that the foreign key must reference the primary key?

<p>Use <code>REFERENCES</code> (A)</p> Signup and view all the answers

How should you transform a ternary relationship EER Diagram to relations?

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

Flashcards

What is a relation?

A named, two-dimensional table of data.

What forms the data structure?

Tables, rows, columns.

What are primary keys?

Unique identifiers of the relation. Guarantees that all rows are unique.

What are foreign keys?

Identifiers that enable a dependent relation to refer to its parent relation.

Signup and view all the flashcards

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. All primary key fields MUST have data.

Signup and view all the flashcards

What is Referential Integrity?

States that any foreign key value MUST match a primary key value in the relation of the one side.

Signup and view all the flashcards

What is Restrict delete rule?

Don't allow delete of “parent” side if related rows exist in “dependent” side.

Signup and view all the flashcards

What is Cascade delete rule?

Automatically delete “dependent” side rows that correspond with the “parent” side row to be deleted

Signup and view all the flashcards

What is Set-to-Null delete rule?

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

Signup and view all the flashcards

How to map Simple attributes?

Simple attributes map directly onto the relation

Signup and view all the flashcards

How to map Composite attributes?

Use only their simple, component attributes.

Signup and view all the flashcards

How to map Multivalued Attribute?

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

Signup and view all the flashcards

How do you map One-to-Many relationships?

Primary key on the one side becomes a foreign key on the many side.

Signup and view all the flashcards

How do you map Many-to-Many relationships?

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

Signup and view all the flashcards

How do you map One-to-One relationships?

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

Signup and view all the flashcards

How associative entities are mapped if Identifier Not Assigned?

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

Signup and view all the flashcards

How associative entities are mapped if Identifier Assigned?

It is natural and familiar to end-users but Default identifier may not be unique.

Signup and view all the flashcards

Mapping One-to-Many(Unary) Relationships

Recursive foreign key in the same relation.

Signup and view all the flashcards

Mapping Many-to-Many (Unary) Relationships

One relation for the entity type and One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity.

Signup and view all the flashcards

Mapping Ternary Relationships

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

Signup and view all the flashcards

Mapping Supertype/Subtype Relationships

One relation for supertype and for each subtype.

Signup and view all the flashcards

What is data normalization?

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 the purpose of data normalization?

The process of decomposing relations with anomalies to produce smaller, well-structured relations.

Signup and view all the flashcards

What is Insertion Anomaly?

Adding new rows forces 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

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 a Candidate Key?

A unique identifier. One of the candidate keys will become the primary key.

Signup and view all the flashcards

What is First Normal Form?

Every attribute value is atomic

Signup and view all the flashcards

What is Second Normal Form?

Every non-key attribute must be defined by the entire key, not by only part of the key

Signup and view all the flashcards

What is Third Normal Form?

no transitive dependencies (functional dependencies on non-primary-key attributes)

Signup and view all the flashcards

What is View Integration?

Combining entities from multiple ER models into common relations

Signup and view all the flashcards

What are 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

  • The relational model comprises data structure, manipulation, and integrity.

Components of the Relational Model

  • The data structure involves tables (relations) with rows and columns.
  • Data manipulation uses powerful SQL operations for data retrieval and modification.
  • Data integrity employs mechanisms to implement business rules, maintaining integrity of manipulated data.

Defining Relations

  • A relation is a named, two-dimensional data table consisting of rows (records) and columns (attributes or fields).
  • To qualify as a relation, a table must adhere to the following:
  • Have a unique name.
  • Ensure every attribute value is atomic (not multivalued or composite).
  • Maintain unique rows with no identical rows across all fields.
  • Ensure attributes (columns) have unique names.
  • Not have importance based on the order of columns and rows.
  • All relations are in the 1st Normal Form.

Relations and E-R Model Correspondence

  • Relations (tables) correspond with entity types and many-to-many relationship types in the E-R model.
  • Rows align with entity instances and many-to-many relationship instances.
  • Columns align with attributes.
  • The term "relation" in relational databases should not to be confused with "relationship" in the E-R model.

Key Fields

  • Keys are special fields which uniquely identify records and establish relationships between tables
  • Primary keys are unique identifiers for a relation, ensuring unique rows using examples like employee or social security numbers.
  • Foreign keys enable a dependent relation to reference its parent relation.
  • Keys can be simple (single field) or composite (multiple fields).
  • Keys also serve as indexes to accelerate response times for user queries

Integrity Constraints

  • Domain constraints define allowable values for an attribute.
  • Entity integrity ensures no primary key attribute is null and all primary key fields have data.
  • Action assertions are business rules derived from Chapter 3
  • Referential integrity dictates that a foreign key value must match a primary key value in the related table unless the foreign key is null.
  • Restrict prevents deletion of a "parent" side if related rows exist in the "dependent" side.
  • Cascade automatically deletes "dependent" side rows corresponding to the deleted "parent" side row.
  • Set-to-Null sets the foreign key in the dependent side to null if deleting from the parent side which is disallowed for weak entities.

SQL Table Definitions

  • Referential integrity constraints are implemented with foreign keys referencing primary keys.

Transforming EER Diagrams into Relations

  • Regular entities' simple E-R attributes map directly onto the relation.
  • Composite attributes use only their simple, component attributes.
  • A multivalued attribute becomes a separate relation with a foreign key from the superior entity.

Mapping Weak Entities

  • Weak entities become a separate relation referencing the superior entity via a foreign key.
  • The primary key for the weak entity must include a partial identifier and the primary key of the identifying relation.

Mapping Binary Relationships

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

Mapping Associative Entities

  • For entities without an identifier, the default primary key includes the primary keys of the associated entities.
  • If an identifier is assigned, using one will be considered natural and familiar, but needs to be unique.

Mapping Unary Relationships

  • One-to-Many associations use a recursive foreign key within the same relation.
  • Many-to-Many associations need two relations, one for the entity type and another associative one using two attributes (its primary key) taken from the original entity's one

Mapping Ternary Relationships

  • Involves one relation for each entity and an additional one for the associative entity.
  • The associative entity holds foreign keys referencing each entity involved in the relationship.

Mapping Supertype/Subtype Relationships

  • Creates one relation for the supertype and each subtype.
  • Supertype attributes are inherited by the supertype relation.
  • Subtype attributes go to into their specific subtypes.
  • A 1:1 relation is established between supertype and subtypes, with the former being the primary table.

Data Normalization

  • Validation and improvement of a logical design ensures satisfaction of constraints while eliminating unneeded data duplication.
  • Transforms anomalous relations into smaller, well-structured relations.

Understanding Well-Structured Relations

  • A well-structured relation will have minimal data redundancy.
  • The design of the Relation also allows users to insert, delete, and update rows minus data inconsistencies.
  • The Goal of a well-structured relation is to reduce or eliminate anomalies.
  • Insertion anomalies happen when rows force duplicate data entry by user.
  • Deletion anomalies results in unintended data loss.
  • Modification anomalies occurs when changes prompts more changes due to duplication.
  • The general rule of thumb is: A table should pertain to one entity type.

Functional Dependencies

  • Functional dependency exists when the value of one attribute (the determinant) determines the value of another attribute.
  • A candidate key is a unique identifier. One of the candidate keys becomes the primary key
  • Each non-key field is functionally dependent on every candidate key.

Normal Forms

  • First Normal Form (1NF): No multivalued attributes and every attribute value is atomic, meaning it cannot be further subdivided.
  • Second Normal Form (2NF): Meets 1NF criteria plus every non-key attribute is fully functionally dependent on the ENTIRE primary key
  • Non-key attributes must be defined by the entire key.
  • Second Normal Form also means that there are no partial functional dependencies.
  • Third Normal Form (3NF): Meets 2NF with no transitive dependencies, and functional dependencies exist only on non-primary key attributes.
  • It is generally considered sufficient as a normal form.

Merging Relations

  • It Combines entities from multiple ER models into common relations (View Integration).
  • When merging entities, watch out for synonyms (attributes with different names but same meaning) and homonyms (attributes with same name but different meanings)
  • Watch for transitive dependencies, since if relations are in 3NF prior to merging, they may not be after merging
  • Be aware of Supertype/subtype relationships, since they may be hidden prior to merging.

Enterprise Keys

  • Primary keys are unique in the whole database, unlike relation-specific keys.
  • The keys Correspond with the object ID concept 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

DCIT 55 - Relational Database Concepts Review
23 questions
Slide 3 - ER-Model-V1
78 questions

Slide 3 - ER-Model-V1

ReliableBlueLaceAgate7739 avatar
ReliableBlueLaceAgate7739
Use Quizgecko on...
Browser
Browser