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 8896859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:11:06+00:00 2026-06-15T00:11:06+00:00

Our Company is developing a CRM and we came now to the point where

  • 0

Our Company is developing a CRM and we came now to the point where we have to decide how we want to handle the releationships. This is an important point because there are going to be tons of them. And changing the structure later would be simply not cool..

I know 3 ways how we could do it:

One releationship table:

The way i would do this is creating one table holding all the releationships.

Table: releationships

+----+-------------+-----------+--------------+------------+
| id | record_type | record_id | belongs_type | belongs_id |
+----+-------------+-----------+--------------+------------+
| 1  | person      | 42        | company      | 12         |
+----+-------------+-----------+--------------+------------+
| 2  | person      | 43        | company      | 12         |
+----+-------------+-----------+--------------+------------+
| 3  | note        | 23        | company      | 12         |
+----+-------------+-----------+--------------+------------+ 
| 4  | attachment  | 13        | company      | 12         |
+----+-------------+-----------+--------------+------------+

Multiple releationship tables:

I think this is the way how it for example the SugarCRM does.

Table: company_realationships

+----+-----------+------------+--------+
| id | record_id | has_type   | has_id |
+----+-----------+------------+--------+
| 1  | 12        | person     | 42     |
+----+-----------+------------+--------+
| 2  | 12        | person     | 43     |
+----+-----------+------------+--------+
| 3  | 12        | note       | 23     |
+----+-----------+------------+--------+
| 2  | 12        | attachment | 13     |
+----+-----------+------------+--------+

All in the record table:

Table: person

+----+-----------+------------+
| id | name      | company_id |
+----+-----------+------------+
| 42 | luke      | 12         |
+----+-----------+------------+
| 43 | other guy | 12         |
+----+-----------+------------+

ect.

  • So my Question is wich is the Best way of handling lots of releationships?
  • Are there other ways to do it?
  • What are disadvantages / advantages?
  • Is there a special way how hightraffic sides handle their releationships?

Thanks for your help guys 🙂

  • 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-06-15T00:11:08+00:00Added an answer on June 15, 2026 at 12:11 am

    So my Question is wich is the Best way of handling lots of releationships?

    The third one or the variation of it (see below).

    Every “M:N” relationship should be represented by its own junction table. OTOH, a “1:N” relationship doesn’t need additional table – just a proper foreign key in the table on the side of the “N”.

    If I understand your description correctly, the third option models a 1:N relationship between company and person. If by any chance you wanted to model a M:N relationship between them, you’d have a junction table: company_person ( company_id, person_id, PK (company_id, person_id) ).

    Are there other ways to do it?

    Sometimes, inheritance (aka. category, subtype, generalization hierarchy etc.) can be used to lower the number of possible “relatable” combinations. In a nutshell, make a relationship to a parent, then every child inherited from that parent is automatically involved in that relationship.

    For an example, take a look at this post.

    What are disadvantages / advantages?

    Enforcing constraints (including FKs) declaratively is better (less prone to errors and probably more performant) than enforcing them through triggers, which is again better than enforcing them in the client code.

    Choose a design that better adheres to that principle. For example, your options 1 and 2 don’t allow the DBMS to enforce FKs declaratively.

    Is there a special way how hightraffic sides handle their releationships?

    Good logical design followed by good physical implementation is the only solid basis for good performance. It’s hard to “bolt-on” the performance on top of a bad design.

    Perhaps, you’d like to take a look at:

    • ERwin Methods Guide
    • Use The Index, Luke!

    And when it comes to performance, don’t guess! Measure on realistic amounts of data.

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

Sidebar

Related Questions

I'm developing a TFS tool to assist the developers in our company. This said
So we have recently started developing applications for the iPad for our company. Unfortunately
Our company is developing a quite large app for the iPad. Eventually we want
I am developing a drop-in component for our company's websites. This component allows users
Greetings, in our company we are developing wcf service. This is used as a
I'm developing an application for our company that eventually will have lots of ways
While aware of the appstore guidelines, specifically IAP usage. Our company is developing an
At our company we are developing an application that will consists of several modules.
I'm developing an internal web app on our company intranet using PHP. One section
I've been tasked with developing an application for internal use in our company, the

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.