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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:54:28+00:00 2026-06-13T08:54:28+00:00

Suppose I have 3 models musician, developer and doctor, each one has some attributes

  • 0

Suppose I have 3 models musician, developer and doctor, each one has some attributes in common, for example name, lastname, birthday and email, but they have some attributes specific for example musician(instrument, band), developer (language, SO) and doctor (licence, clinic).

My approach is something like this:

class Person < ActiveRecord::Base
    belongs_to :general, :polymorphic => true
end

class Musician < ActiveRecord::Base
    has_one :person, :as => general
end

class Developer < ActiveRecord::Base
    has_one :person, :as => general
end

class Doctor < ActiveRecord::Base
    has_one :person, :as => general
end

The question is, this kind of model relationships affects performance because of the polymorphic association?, or are there a better solution to consider?

  • 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-13T08:54:29+00:00Added an answer on June 13, 2026 at 8:54 am

    Yes, polymorphic association does affect performance. Sometimes positively, sometimes negatively, all dependent on how your application is used.

    As far as the case you presented in concerned, I would not used polymorphic association. I would just have 3 models, with common attributes like name, lastname, birthday and email all in three models. This is more advantageous because if you wanted to find out the name of a musician, you only need to make 1 database call in Musician table. In polymorphic association case, you need 2 database calls in Musician table and Person table.

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

Sidebar

Related Questions

Suppose I have 2 models. The 2nd model has a one-to-one relationship with the
Let's suppose we have these three models: - cagegory ( id, name ) -
(sorry for any bad English) Let's suppose I have models A, B, C. Each
Suppose I have two models A and B Now I want to copy some
I have 2 models which are related to each other using One to One
Suppose I have the classes/models Projects (has many lists) Lists I want to allow
Suppose I have two models, Book and Page, such there is a one-to-many relationship
I have a question about the way Django models the one-to-one-relationship. Suppose we have
Suppose I have something like this in my models.py: class Hipster(models.Model): name = CharField(max_length=50)
Suppose, I have models: public class Person { public sting Name {get;set;} public List<Book>

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.