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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:31:31+00:00 2026-05-26T13:31:31+00:00

I’m trying to learn NHibernate, and I’ve stumbled into a combined database design /

  • 0

I’m trying to learn NHibernate, and I’ve stumbled into a combined database design / “learning how NHibernate works” issue.

In my case, I’m trying to design a simple table with rows and columns, where each row has a “description” and then has a list of “column values” (of sorts), which contains the data as well as sorting information. In code, it’d look something like this:

public class Row
{
    public virtual int ID { get; set; }
    public virtual string Description { get; set; }
    public virtual ICollection<Column> Columns { get; set; }
}

public class Column
{
    public virtual Row ParentRow { get; set; }
    public virtual int SortID { get; set; }
    public virtual string Value { get; set; }
}

My ultimate goal was to create a database schema that would be…

  • Two tables, “Row” and “Column”
  • Row has two columns: ID and Description.
  • Column has three columns: ParentID, SortID, and Value.

Because a column can only belong to one row, and ideally each column would have a unique sort ID within each ParentID, the primary key of the Column table could be ParentID and SortID, instead of having a fourth “ID” column.

However, NHibernate is fighting me at every turn. It insists that I must have an ID for the Column field. I suppose I have a few questions:

  1. Is my “schema goal” in and of itself that seriously flawed? Would it really be a better design for each Column to have its own ID? If so, why?
  2. Regardless of whether or not the schema I’m looking for is a good design, can this be accomplished in NHibernate? Thus far, I’ve successfully mapped the “Row” class, but I cannot map the “Column” class without NHibernate complaining that I have to provide it with an ID. (for what it’s worth, I’m using Fluent NHibernate). How do I circumvent that?
  • 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-26T13:31:32+00:00Added an answer on May 26, 2026 at 1:31 pm

    ORMs in general can map both Primary Keys and Composite Primary Key Identifiers. From those two options, you should choose what works best for your use case.

    To learn how to map Composite Primary Key Identifiers, read composite-id section from the Nhibernate documentation.

    All that said, from experience, I’ve found that non-composite primary key identifiers are your ORMs best friend. It makes life a lot easier in many cases, such as, application based id generation, batching etc. In tables similar to your “column” table I prefer to have a synthetic primary key identifier (Surrogate key). But again, it depends on your need, YMMV.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.