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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:24:03+00:00 2026-05-12T00:24:03+00:00

Suppose I have 2 tables in a database. eg: Dog & Boss This is

  • 0

Suppose I have 2 tables in a database.
eg: Dog & Boss
This is a many to many relationship, cause a boss can have more than 1 dog, and a dog can have more than 1 owner. I am the owner of Bobby, but so is my wife.

But many to many is not allowed, so there is a helpertable: DogsPerBoss

How to model this in code?

Class Boss can have a collection of Dogs.
Class Dog can have a collection of Bosses.
–> at least, that is what I think. Perhaps there are better solutions?

How about extra data that is in the helper-table?
Should that be in de Boss-class or in the Dog-class?
eg: Nickname
(I call the dog “good boy” and my wife calls him “doggie”)

I hope my question is kinda clear?
Are there any best-practices on what is the best way to achieve this?
Can you give me some references?

An ORM (like NHibernate) is not an option.

  • 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-12T00:24:04+00:00Added an answer on May 12, 2026 at 12:24 am

    Why are you talking about tables? Are you creating an object model or a database model?

    For an object model, there’s no reason a Dog can’t have a List<Owner> and an owner have a List<Dog>. Only if you have attributes on the relationship do you need an intermediate class (what UML calls an Association Class). That’s when you’d have a DogOwnership class with extra properties, and each Owner would have a List<DogOwnership>, and so would each Dog. The DogOwner would have a Dog, an Owner, and the extra properties.

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

Sidebar

Related Questions

Suppose I am building an app using current mysql database tables. I have this
Suppose I have a big database, about 800 tables. In this database there is
Suppose I have a database data1 which gives me this: show tables; table1 table2
Suppose I have two tables on a database, T 10 and T 11 ,
Suppose I have the following tables in my database: Now all my queries depend
Suppose I have a custom file format, which can be analogous to N tables.
Suppose we have a PostgreSQL database with two tables A, B. table A columns:
Suppose I have a database containing 3 tables in a grails application: User Activity
Suppose I have database tables: user id username plan 1 ahmad Note: plan is
Suppose this is what I have in my database table Ancestor ( idAncestor int

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.