Ask Your Question

db's profile - activity

2015-02-24 12:08:13 +0200 received badge  Famous Question (source)
2015-02-17 04:16:07 +0200 received badge  Enthusiast
2015-02-11 22:36:34 +0200 received badge  Notable Question (source)
2015-02-11 02:40:11 +0200 commented answer How to populate foreign key on child record creation

The vendor can only have one address and the contact can only have one address per record hence the reason to have the foreign key addressid on both the vendor and contact table. This seems like a standard relationship where I can have many contacts that use the same address. The trick is when I create the contact I want to also be able to create the child address record and populate the primary key of the address in the contact table. How would base normally handle a situation like this.

2015-02-10 23:49:20 +0200 received badge  Popular Question (source)
2015-02-10 12:15:35 +0200 commented answer How to populate foreign key on child record creation

I have one ADDRESS for many CONTACTs. I also use the ADDRESS table as a child to several other tables in my database such as VENDORS, etc. If I flip the relationship thie issue that I see arising is that I would have to have multiple foreign keys on the ADDRESS table, CONTACTID, VENDORID, etc.This besides from making it a one to many in the other directions this would cause more issues with other forms.

2015-02-10 04:05:47 +0200 asked a question How to populate foreign key on child record creation

I am sure this is an easy answer that I am missing. I have lots of experience with Relational DBs but I am new to Libre Base. I have created a Form called contact that has a source of the table CONTACT. The contact table has a foreign key of ADDRESSID that references the ADDRESS table. I then have a sub form that has a source of the ADDRESS table. The linked fields are set to ADDRESSID.

The problem happens when I create new records. I type data in the main form for the contact and then in the subform for the address. When I save the record the primary key is created in the ADDRESS table but then it is not populated as a foreign key for the newly created contact in the CONTACT table.

Any help would be greatly appreciated.

Using libre office Version: