M:M to 1:M conversion

Cards (42)

  • What does the course_id column represent in the StudentCourses table?
    The unique ID of a course
  • What does the student_id column represent in the StudentCourses table?
    The unique ID of a student
  • How does the StudentCourses table maintain the one-to-many relationship?
    Each student can have many courses listed
  • What type of relationship does the intermediary table help to create?
    One-to-many relationships
  • What does an m:m relationship involve?
    Two tables referring to each other many times
  • What is the purpose of creating an intermediary table in a database?
    To change many-to-many relationships to one-to-many
  • What is the purpose of the intermediary table in a 1:m relationship?
    To link students to courses one-to-many
  • What does the foreign key course_id reference in the StudentCourses table?
    It references the Courses table
  • What are the key attributes of an m:m relationship in databases?
    • Involves two tables
    • Each table can have multiple references
    • Requires an intermediary table for conversion to 1:m
  • How do we convert an m:m relationship to 1:m?
    By creating an intermediary table
  • What is the name of the intermediary table connecting students and courses?
    StudentCourses
  • How do the values in the StudentCourses table relate to the Students and Courses tables?
    They point back to their primary keys
  • What are the two columns in the StudentCourses table?
    student_id and course_id
  • What is the name of the relationship shown in the image?
    Many to many relationship
  • What are the advantages of using a many-to-many relationship in this scenario?
    • Allows for more flexibility and scalability in the data model
    • Avoids data duplication and redundancy
    • Simplifies queries and data management
  • How would the StudentCourses table look if student 101 is taking courses 201 and 202?
    • student_id: 101, course_id: 201
    • student_id: 101, course_id: 202
  • What are the attributes of the course entity?
    id, course_name
  • What relationship does adding foreign keys maintain between students and courses?
    It maintains a one-to-many relationship
  • What are the two entities shown in the image?
    student and course
  • What does the foreign key student_id reference in the StudentCourses table?
    It references the Students table
  • What are the attributes of the student entity?
    id, student_name
  • What is the purpose of adding foreign keys in the intermediary table?
    To link it with the original tables
  • How would you represent this many-to-many relationship in a database?
    • Create a junction/bridge table with the connecting attributes (student_id and course_id)
    • This allows a student to be enrolled in multiple courses and a course to have multiple students
  • What are the values of course_id in the StudentCourses table?
    201 and 202
  • What is the structure of a new intermediary table in a relational database?
    • Contains foreign keys from both related tables
    • Each foreign key represents a relationship
    • May include additional attributes relevant to the relationship
  • What are the connecting attributes between the student and course entities?
    • student_id
    • course_id
  • What type of relationship is established between Student and Course after the adjustment?
    One-to-many (1:m)
  • What is the name of the intermediary table used in the 1:m relationship?
    Student_Course
  • What does the table independence mean in this context?
    There is no direct connection between Student and Course tables
  • What was the relationship type between Student and Course before the adjustment?
    Many-to-many (m:m)
  • What are the disadvantages of using a many-to-many relationship in this scenario?
    • Increased complexity in the data model
    • More tables to manage and maintain
    • Potential performance issues with complex queries
  • What is the significance of maintaining independence between Student and Course tables?
    It allows for more flexible data management
  • What does the term "foreign keys" refer to in this context?
    Keys used to link tables together
  • What happens to the direct link between Student and Course tables?
    It is removed to maintain independence
  • How do the Student and Course tables connect after the adjustment?
    Through the intermediary table using foreign keys
  • What are the implications of maintaining table independence in a database?
    • Reduces redundancy
    • Enhances data integrity
    • Allows for easier updates
    • Supports scalability
  • What is the purpose of the intermediary table in the relationship between Student and Course tables?
    To link Student and Course tables
  • Why is it important to verify the new 1:m relationships?
    To ensure accurate representation of data
  • What changes occur in the relationship between Student and Course tables before and after the adjustment?
    • Before: Direct link (m:m)
    • After: Indirect link (1:m) through Student_Course
  • How does the intermediary table facilitate the 1:m relationship?
    It allows multiple entries for students and courses