[Solved] How show a many-to-many relation in a form?

Discuss the database features
Post Reply
Bazsl1
Posts: 29
Joined: Mon Aug 03, 2015 8:07 pm

[Solved] How show a many-to-many relation in a form?

Post by Bazsl1 »

Assume I have a many-to-many relationship between table A and table B that is implemented using a linking table L.
1) The linking table must have a primary key that consists of two columns. Can I define a multi-column primary key in Base? If not, can I create the linking table using DDL and create a muli-column primary key?

2) Is it possible to display the one-to-many relationship from table A to table B in a form? I can't see how to include the one-to-many link from A to L and the one-to-one link from L to B in a form since forms only support one level of sub-form.

Thanks.
Last edited by Bazsl1 on Thu Mar 17, 2016 12:36 am, edited 1 time in total.
OpenOffice 4.1.2 on Windows 10 Pro
User avatar
Villeroy
Volunteer
Posts: 31349
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How show a many-to-many relation in a form?

Post by Villeroy »

[Example] Relations reflected by list boxes in forms
The recipe is:
A in the main form (either way as grid or details).
L in the subform linked through the common A.IDs implemented as a grid of B.IDs. No need to show the A.ID.
Implement the grid's displayed B.IDs as a column of list boxes showing SELECT B.string, B.ID FROM B ORDER BY B.string

When editing the related data, you select B.items into the L.grid which belong to the current A.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply