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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:43:19+00:00 2026-05-28T04:43:19+00:00

I currently create a Repository for each database table and a corresponding data class

  • 0

I currently create a Repository for each database table and a corresponding data class for the column values (object to pass around data).

I recently started using some 1 to 1 relationships and I’m not sure what would be the best way to implement them.

For example

If I have a User table and a UserSettings Table in a 1:1 relationship.

// Data classes (Holds all the field value for the table)
    public class User
    {
        public int UserId { get; set; }
        public string Name { get; set; }       
    } 


     public class UserSettings
        {
            public int UserId { get; set; }
            public bool SomeSetting { get; set; }       
        } 

Questions:

  1. Should I always go through the User object to manipulate the UserSettings object, or should I be able to manipulate them
    independently?
  2. Should I include the primary key field in the UserSettings object?
  3. Should I store a reference to the USerSettings object in the User object?

  4. Do I make two repo’s one for User and one UserSettings, or do I handle everything in the Users Repo.

  • 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-28T04:43:19+00:00Added an answer on May 28, 2026 at 4:43 am

    The only time I’ve ever found a 1:1 relationship between aggregate roots to be useful is when the aggregate roots on either side of the relationship are managed by different domains. They must share the same primary key, and therefore if they are both managed by the same domain then they are by definition parts of the same aggregate root. I think you need to approach this question from a different angle:

    1. Is the User object only going to exist for this application?
    2. Do you expect that to always be the case?

    If the User is a concept that resides entirely inside of this domain, then there’s no reason to have a UserSettings aggretate root that has a 1:1 relationship with a User; you simply make User.Settings a way to retrieve the UserSettings for that User. (And of course that obviates the need for a repository – it becomes the responsibility of the UserRepository to hydrate the UserSettings when it hydrates everything else on the User.)

    But, if the User will eventually inform sessions for multiple domains, then User needs to represent its own domain, the services of which your application will consume. Then, you gain a very real need to separate the UserSettings of this application from those of a different application. The User is not specific to this application, but the UserSettings for that User is.

    NOTE – In the interest of not refactoring your project at this point, if the answer to either question 1 or 2 above is “no”, then you should make UserSettings a separate aggregate root within the same domain, in order to create a seamless transition when you eventually do move User into its own domain.

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

Sidebar

Related Questions

I'm currently trying to create a kernel module that will produce data based on
I am currently trying to create a function which will allow me to pass
I'm currently trying to create a desktop like homepage where using can move around
i'm working with a multi-threaded program (using pthreads) that currently create a background thread
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
I'm creating an installer for my Windows client application. Currently I create an MSI
I'm currently attempting to create a tabbed interface in a web application, and based
I am currently trying to create a win32 service using pywin32. My main point
I am currently trying to create a menu system for a game and cannot
I'm currently trying to create a program that estimates location based on signal strength.

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.