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

  • Home
  • SEARCH
  • 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 198371
In Process

The Archive Base Latest Questions

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

Can someone help me understand how best to model a composition relationship? If for

  • 0

Can someone help me understand how best to model a composition relationship?

If for instance I have a student whom can have many schedules, I would create roughly:

class Student
{
  prop long Pk { get; set; }
  prop string Name { get; set; }
  prop List<Schedule> Schedules { get; set; }
}

class Schedule
{
  prop string Semester { get; set; }
  prop List<Course> Courses{ get; set; }
}

Somewhere down the line I may have a Schedule object, and will wish to identify which student it belongs to. I want to be able to write Schedule.Student.Name, and receive the student’s name in return. Do I add a Student property to my Schedule object as well?

My application has been passing a Student Pk to my Schedule object in order to do CRUD functionality. I’m keeping the Student PK as a private variable in order to keep a handle on it if I need it.

As my application becomes more complex, I’m finding it hard to maintain what I’ve been doing. What are your suggestions for me? What else can I consult (books/links) to get a refresher and better handle on these fundamentals?

  • 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-11T16:55:55+00:00Added an answer on May 11, 2026 at 4:55 pm

    “I want to be able to write Schedule.Student.Name, and receive the student’s name in return. Do I add a Student property to my Schedule object as well?” Yes.

    What you are describing (supporting both foreign keys for lookup and object references for easy navigation of the object graph) sounds like a really good match for an object-relational mapper (ORM). A good ORM will automatically load the associated object/objects for you using the FK/PK (e.g. if the Schedule has a StudentPK field then the mapper will handle loading/mapping of the Student property for you). There are many products of this type: you can use built-in .NET frameworks such as the Entity Framework, open-source ones such as NHibernate or commercial products such as LightSpeed, LLBLGen, EntitySpaces or OpenAccess (disclosure: I work for a company that makes a commercial ORM). Google for ORM or object-relational mapper, or check Wikipedia, for an overview of the kind of thing I’m describing.

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

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Windows.Pas function GetTempFileName(lpPathName, lpPrefixString: PWideChar; uUnique: UINT; lpTempFileName: PWideChar): UINT;… May 12, 2026 at 1:13 pm
  • Editorial Team
    Editorial Team added an answer if no service is running, then sql server is not… May 12, 2026 at 1:13 pm
  • Editorial Team
    Editorial Team added an answer d is a pointer to an array of CRectangle objects… May 12, 2026 at 1:13 pm

Related Questions

I have an application that has multiple states, with each state responding to input
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
Currently I am working with Java and its object oriented-design aspects (I also work
Consider the following: volatile uint32_t i; How do I know if gcc did or

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.