Jump to content

Breed Percentage


carleihar

Recommended Posts

I've been thinking about this for a while, but I just can't seem to figure out how to do it. First, I have a SQL database with a list of horses and their unique characteristics. I have made a program that takes information from two horses and uses the information to create a totally new horse. One characteristic I am stuck on is breed. I would like to show the percentage of each breed that is in the horse. So if a 50% Quarter Horse and a 50% Throughbred is combined with a 100% Warmblood, it should show percentages accordingly. Any help?

Link to comment
Share on other sites

So you're confused about how to store it, right?  Not the math?  (The math is just half everything.)

 

 

I would probably just put it in a table like so:

 

CREATE TABLE breeds (

    breed_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

    breed_name VARCHAR(255)

);

 

CREATE TABLE horse_breeds (

    horse_id INT NOT NULL,

    breed_id INT NOT NULL,

    part TINYINT NOT NULL

);

 

And part would range from 1-100 and represent a percent.

Link to comment
Share on other sites

In corbin's example, the horse_breeds table doesn't have a primary key but the horse_id is repeated; multiple rows represent one horse.

 

So let's say HorseA is a breed of 20% of HorseB and 80% of HorseC.  The tables would look like the following (see first two rows of horse_breeds:

 

 

breeds:

{1, HorseB}

{2, HorseC}

{3, HorseD}

{4, HorseE}

 

horse_breeds:

{1, 1, 20}<--{unique identifier for the horse, HorseB, 20%}

{1, 2, 80}<--{unique identifier for the horse, HorseC, 80%}

{2, 2, 50}<--{unique identifier for the second horse, HorseC, 50%}

{2, 3, 10}<--{unique identifier for the second horse, HorseD, 10%}

{2, 4, 40}<--{unique identifier for the second horse, HorseE, 40%}

 

Also, it wouldn't hurt to give the horse a name:  horse_breeds.name

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.