Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 765605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:54:43+00:00 2026-05-14T16:54:43+00:00

I have 4 tables, linked in a circular reference – I remember from college

  • 0

I have 4 tables, linked in a circular reference – I remember from college that I was told this is bad however there are exceptions…I am hoping that this is one of them 🙂

My database contains 4 tables; teachers, classes, subjects and teachers_classes.

The following sums up my relationships:

  • A teacher can have many classes
  • A class can have many teachers (so teachers_classes eliminates the many-to-many here).
  • A class can have many subjects
  • A subject can only have 1 class
  • A teacher can have many subjects

If you can visualise this, my ERD looks like a square (or circle)… I have already built my simple app, and was prompted by someone else to check this problem.. please someone tell me ths is an exception and why? I cannot remember any of the stuff I was taught about this, but my application appears to work totally fine for what I want it to do!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:54:43+00:00Added an answer on May 14, 2026 at 4:54 pm

    Circular references can be bad for a couple of reasons:

    1. In the case where the relationships must exist (i.e., a teacher must have a class and a class must have a teacher, both from a business and technical requirement perspective), you run into a chicken-or-the-egg scenario: you can’t add a teacher without a class, nor can you add a class without a teacher.
    2. It makes it difficult to figure out what’s at the “top” of the heirarchy (since, truthfully, there isn’t a “top”)

    Assuming that you can have teachers without classes and/or subjects without classes, it sounds like one of those two would be the “top” (from a business perspective, I’d assume that it would be subjects).

    If what you have is working, I don’t see an issue with the design, nor do I see an alternative way of designing it.


    Edit after comment

    There isn’t an issue with one-sided dependency (that’s just what a plain ol’ non-nullable foreign key is).

    I feel like I should point out something as well, based upon your comment: the objections to circular dependencies are technical, not logical. If the business says that there can be no teachers without classes and no classes without teachers, that’s fine; you just can’t model the data that way or you’ll never be able to add anything. You have to define which one of those objects–classes or teachers–is allowed to exist in isolation (from a technical perspective, not a business one).

    You’re somewhat saved by the fact that you have a M:M relationship between teachers and classes, because this forces you to make both able to exist in isolation (since the connection is made in a link table, rather than in the participant tables themselves.

    Because of this, you do not have a true circular dependency. Your business logic is circular, but that’s fine, since you have complete control over how it operates. Your layout either looks like this:

       Teacher <----- TeacherClass -----> Class
          ^                                 ^
          |                                 |
          |                                 |
    TeacherSubject --------------------> Subject
    

    (If a teacher can have multiple subjects)

    Or this:

       Teacher <----- TeacherClass -----> Class
          |                                 ^
          |                                 |
          |                                 |
          \----------------------------> Subject
    

    (If a teacher can have only one subject)

    Or this:

       Teacher <----- TeacherClass -----> Class
          ^                                 ^
          |                                 |
          |                                 |
          \----------------------------- Subject
    

    (If a subject can have only one teacher)

    In the first case, both Teacher and Class are top-level entities, since neither of them points to anything else (the link tables accomplish this). In the second, only Class is a top-level entity.

    As long as there’s a top-level entity somewhere on the path, you’re fine. In the first, you can add records in this order:

    Teacher -> Class -> (TeacherClass -> Subject) -> TeacherSubject
    

    (I enclosed TeacherClass -> Subject in parens because you could add those in any order)

    In the second, you can add them in this order:

    Class -> Subject -> Teacher -> TeacherClass
    

    In the third, you can add them in this order:

    Class -> Teacher -> (TeacherClass -> Subject)
    

    So, from a technical perspective, you don’t have a true circular dependency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following situation. A main table and many other tables linked together with
In my database I have tables that define types for example Table: Publication Types
When I have tables in my database that have PK/FK relationships (int) and when
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have two tables that are joined together. A has many B Normally you
I have three database tables: users emails invitations Emails are linked to users by
I have two tables linked via a HABTM. countries & networks. They are linked
I have two tables linked together through the 3rd table threads: id, name tags:
I have two tables linked by an ID column. Let's call them Table A
I have two tables, timetable and lesson_booking these are linked via timetable_id . timetable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.