Base Database - Recording relationships between my cows

I am creating a database to store information about my herd of cows. I want to record for each cow who their parents are, but the ID for each cow is in the same table. How do I link between any given cow and its parents if all the cow details are in the same table?

Here are the details of the version I’m using in case that helps.
Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.5-0ubuntu0.24.04.2
Calc: threaded

Let’s show it simple, all in one table:

ID → Integer, Primary Key
Name → VARCHAR
Sex → VARCHAR(1), ‘f’ or ‘m’
f_ID → Integer, Foreign Key to the female parent cow
m_ID → Integer, Foreign Key to the male parent cow

You will create a form, where f_ID and m_ID will be filled by a listbox, which shows all names of female or male cows.

In English, these are called bulls; cow is the female. Unless there are trans-gender bovines in which case I have no idea :frowning:

Thanks RobertG - I’ve been overthinking the tables rather than using the form.

Please be so kind to remember that the son of a cow is a veal (chicken or veal?).

With kind regards

…is a calf! ( veal )

@karolus

Thanks very much, I appreciated…

Hi Robert,

Could you point me in the direction of some instructions on how to create the form with the listbox please?

Thanks,
Wayne

First things first. What else goes into that table? Birth date? Ear mark ID?

Hi Villeroy,
I attach a screen shot where I have added the fields for mother and father as integers.

I have been trying to create a form that will allow me to select the mother and father cows using their Cow ID, but have failed. Robert G’s response implies that it is straightforward to use a form to enter the apropriate information, but I have been unable to work out how to do it.
Regards,

Wayne
image

@Verny56 Create a form for the table. Could be a form with standalone fields or a form with a tablecontrol. Change the fields for “Mother” and “Father” to listboxes. Set this code for the listbox:

SELECT "Registered Name", "Cow ID" FROM "Tablename" WHERE "Gender" = 'f'

for the cow and "Gender" = 'm' for the bull. Don’t know if you use ‘f’ and ‘m’. Also can’t see the name of the table. The “Registered Name” will be shown, the “Cow ID” will be written to the table.

Several years ago, I created this: https://www.mediafire.com/file/qvd4cap41tbte0m/Pedigree.zip/file for another forum. It is about horses. The input form takes individual animals with ancestors and owners (with listboxes for fathers and mothers). The spreadsheet offers two methods to illustrate the bloodline. The sheet and the external form require database registration via Tools>Options>Databases, register as “Pedigree”

This worked a treat, thank you!

Thanks also to Villeroy for the pedigree example, I shall be looking at that in detail as well.

I’m gratefull to everyone who helped me out.