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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:27:34+00:00 2026-05-10T17:27:34+00:00

How would one structure a table for an entity that can have a one

  • 0

How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I’m working on an app to track animal breeding. Each animal has an ID; it’s also got a sire ID and a dame ID. So it’s possible to have a one to many from the sire or dame to its offspring. I would be inclined to something like this:

ID INT NOT NULL PRIMARY KEY SIRE_ID INT  DAME_ID INT 

and record a null value for those animals which were purchased and added to the breeding stock and an ID in the table for the rest.

So:

  1. Can someone point me to an article/web page that discusses modeling this sort of relationship?
  2. Should the ID be an INT or some sort of String? A NULL in the INT would indicate that the animal has no parents in the database but a String with special flag values could be used to indicate the same thing.
  3. Would this possibly be best modeled via two tables? I mean one table for the animals and a separate table solely indicating kinship e. g.:

    Animal

    ID INT NOT NULL PRIMARY KEY

    Kinship

    ID INT NOT NULL PRIMARY KEY FOREIGN KEY

    SIRE_ID INT PRIMARY KEY FOREIGN KEY

    DAME_ID INT PRIMARY KEY FOREIGN KEY

I apologize for the above: my SQL is rusty. I hope it sort of conveys what I’m thinking about.

  • 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. 2026-05-10T17:27:35+00:00Added an answer on May 10, 2026 at 5:27 pm

    Well, this is a ‘normal’ one-to-many relationship and the method you suggest is the classical one for solving it.

    Note that two tables are denormalized (I can’t point out exactly where the superkey-is-not-well-should-be-subset-of-other-key-fsck-I-forgot part is, but I’m pretty sure it’s there somewhere); the intuitive reason is that a tuple in the first one matches at most a tuple in the second one, so unless you have lots of animals with null sire and dame IDs, it’s not a good solution in any prospect (it worsens performance — need a join — and does not reduce storage requirements).

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

Sidebar

Ask A Question

Stats

  • Questions 293k
  • Answers 293k
  • 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 fgets also reads the '\n' (newline) character. You should remove… May 13, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer I don't know if that is what you are doing… May 13, 2026 at 6:30 pm
  • Editorial Team
    Editorial Team added an answer Base64 encode it. For example: $ openssl base64 < sound.m4a… May 13, 2026 at 6:30 pm

Related Questions

I'm a little stumped on this one. Anyone have any ideas? I'll try to
In one of my projects, I have an application that manages several clients (or
We are working on a datawarehouse for a bank and have pretty much followed
I have an entity model where the base class in an inheritance structure has

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.