I am trying to build a simple database to help me track animals on my trail cameras. I have multiple fields in my primary table that I am trying to reference separate tables data. For example, I have table_main that includes the field “location” in it. How do I get that to reference the table “table_locations” that has all of my camera locations pre-populated? My hope is to get a dropdown list of the locations when I build the form. Currently table_locations has 2 fields; id(primary key, auto integer) and locations. I have tried building a relationship but keep getting an error about foreign keys, when I did some reasing, I see a lot about foreign keys but no information about assigning them, or even if I am going about it the right way.
Hello,
It sounds as if your table connections are reversed. A primary table should be just that - basic information. Secondary tables have related information and you link records back to the primary record. You may want to take a bit of time to look at some of the documentation. The manuals are located here → LibreOffice Base Guide. Chapter 3 - Tables has much of the information you are looking for.
There is also the On-Line documentation → LibreOffice 7.2 Help
Searching will provide pages such as Database Overview
Generally your primary table has a primary key and secondary tables have a primary key and a second non key field containing the key of the primary table it relates to. The documentation will explain the method(s) to generate the relationship.
Have a look at the error. It will try to explain what is going wrong.
Your field in “table_locations” is INTEGER. There must be a field of type INTEGER in “table_main”, which could be populated with the values of primary key in “table_locations”.
If there are values in the field in “table_main”, the same values have to be in “table_locations”. Best way is to link to an empty field in “table_main”.