Database Keys and Relationships
24 Questions
0 Views

Database Keys and Relationships

Created by
@ExcellentCurium

Podcast Beta

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is a Primary Key (PK) used for in a relational model?

  • It defines foreign key relationships.
  • It creates composite keys with multiple attributes.
  • It serves as a unique identifier within a relation. (correct)
  • It restricts values in attributes.
  • Which statement best describes a Foreign Key (FK)?

  • It creates a synthetic primary key.
  • It can only be associated with a single attribute.
  • It establishes a relationship between two tables. (correct)
  • It must uniquely identify each record in its own table.
  • Which type of key is formed using two attributes to create a unique identifier?

  • Alternate Key
  • Surrogate Key
  • Composite Key (correct)
  • Foreign Key
  • What is the role of Integrity Constraints in a database?

    <p>They ensure that CRUD operations are performed without corrupting the database.</p> Signup and view all the answers

    Which of the following is NOT a type of integrity constraint?

    <p>Attribute Constraints</p> Signup and view all the answers

    What is a Surrogate Key?

    <p>A unique key that is generated automatically by the database.</p> Signup and view all the answers

    What does an Alternate Key (AK) consist of?

    <p>All Candidate Keys except the Primary Key.</p> Signup and view all the answers

    In referential constraints, what is required for a foreign key in the referencing table?

    <p>It can only be NULL or match a primary key in the referenced table.</p> Signup and view all the answers

    What does cardinality in relationships refer to?

    <p>The number of entities to which another entity can be associated via a relationship.</p> Signup and view all the answers

    Which type of relationship is exemplified by a citizen owning a vehicle?

    <p>One to many</p> Signup and view all the answers

    What does total participation in a relationship mean?

    <p>Every entity instance must take part in at least one relationship instance.</p> Signup and view all the answers

    In a many to many relationship, which scenario is correct?

    <p>Multiple customers can purchase multiple products.</p> Signup and view all the answers

    Which type of participation involves not all entities being involved in a relationship instance?

    <p>Partial participation</p> Signup and view all the answers

    Which example illustrates a many to one relationship?

    <p>Employees working in a department.</p> Signup and view all the answers

    What kind of entity has total participation constraints?

    <p>Weak entity</p> Signup and view all the answers

    Which of the following statements about cardinality is false?

    <p>One to many allows entities from both sides to connect to multiple counterparts.</p> Signup and view all the answers

    What is the purpose of a NOT NULL constraint in a database?

    <p>To ensure every element has a value</p> Signup and view all the answers

    What characteristic must a primary key possess?

    <p>It must contain unique and not null values</p> Signup and view all the answers

    Which statement accurately describes the function of a FOREIGN KEY?

    <p>It prevents actions that can lead to data loss between related tables</p> Signup and view all the answers

    What is the role of the UNIQUE constraint in a database?

    <p>To restrict the column values to be different from one another</p> Signup and view all the answers

    Which integrity constraint checks that data adheres to specific conditions?

    <p>CHECK</p> Signup and view all the answers

    When converting an ER diagram to a relational model, what does a strong entity become?

    <p>An individual table with attributes as columns</p> Signup and view all the answers

    What does a DEFAULT constraint do in a database?

    <p>It sets a default value if none is provided</p> Signup and view all the answers

    Which of the following constraints relates one table's primary key to another table?

    <p>FOREIGN KEY</p> Signup and view all the answers

    Study Notes

    Primary Key (PK)

    • Selected from a candidate key (CK) set with the least number of attributes.
    • Unique identifier for records in a database table.

    Alternate Key (AK)

    • All candidate keys excluding the primary key.

    Foreign Key (FK)

    • Establishes relationships between two tables.
    • In a relation (r1), an attribute can reference the primary key of another relation (r2).
    • r1 is the referencing (child) relation; r2 is the referenced (parent) relation.
    • Facilitates cross-referencing between different relations.

    Composite Key

    • Primary key formed using at least two attributes.

    Compound Key

    • Primary key which consists of two foreign keys.

    Surrogate Key

    • Synthesized primary key automatically generated by the database, typically an integer.
    • Often used as the primary key for a table.

    Integrity Constraints

    • Ensures CRUD operations uphold database consistency.
    • Prevents accidental data corruption with various constraints.

    Domain Constraints

    • Restricts attribute values in a relation and defines data types.
    • Example: Enrollment constraints based on candidate birth year.

    Entity Constraints

    • Every relation must have a primary key; primary key cannot be NULL.

    Referential Constraints

    • Maintains consistency between two relations.
    • Requires matching values for foreign keys in the referencing relation and primary keys in the referenced relation.
    • Ensures foreign key is either NULL or exists in the parent table.

    Key Constraints

    • Six key constraints in database management systems:
      • NOT NULL: Ensures all values in a column are present.
      • UNIQUE: Guarantees all values in a column are distinct.
      • DEFAULT: Sets a default value for a column if none is specified.
      • CHECK: Maintains data integrity before and after CRUD operations.
      • PRIMARY KEY: Uniquely identifies each entity without NULL values.
      • FOREIGN KEY: A common attribute that maintains relationships between tables.

    Transforming ER Model to Relational Model

    • Both ER and relational models represent real-world entities abstractly, following similar design principles.
    • Transforming ER diagrams into a table format leads to relational database design.

    ER Diagram Notations to Relations

    • Strong Entity: Becomes a table, with attributes as columns.
    • Example: Employee working on a branch or job.

    Relationship Constraints

    Mapping Cardinality

    • Defines the association between entity sets:
      • One to One: Each entity in A associates with at most one entity in B (e.g., Citizen has Aadhar Card).
      • One to Many: An entity in A associates with N entities in B (e.g., Citizen owns a Vehicle).
      • Many to One: An entity in A can relate to at most one entity in B (e.g., Course taken by Professor).
      • Many to Many: Entities in A can associate with multiple entities in B and vice versa (e.g., Customer buys a product, Student attends a course).

    Participation Constraints

    • Partial Participation: Not all entities are involved in a relationship instance.
    • Total Participation: Each entity must be involved in at least one relationship instance (Example: Customers must be involved in loans, but loans can exist without all customers).

    ER Notations

    • Utilized for modeling database schemas.

    Extended ER Features

    • Basic ER features are sufficient for simple databases, while complex schemas benefit from extended ER features.
    • Specialization allows for more detailed modeling of entities and relationships.

    Studying That Suits You

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

    Quiz Team

    Related Documents

    DBMS_Full_Notes.pdf

    Description

    Test your knowledge of database keys including Primary Key, Alternate Key, and Foreign Key. This quiz covers their definitions, relations among tables, and the role of attributes in database management. Perfect for anyone studying database concepts.

    More Like This

    Use Quizgecko on...
    Browser
    Browser