many-to-many

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
tloosle
Posts: 2
Joined: 2014-05-28 16:56

many-to-many

Post by tloosle » 2014-05-28 17:00

I get a circular reference error and it tells me to create a third table. Lost on this??

I have a table called units and one called tenants.

If I browse tenants I want to see what unit they are in and if I browse units I want to see which tenant is in that unit. How can I do this with a third table?

dssc
Posts: 12
Joined: 2014-01-28 08:30
Location: UK

Re: many-to-many

Post by dssc » 2014-05-28 17:43

Create a third table, say, "occupations"
Look up in that table the "tenant" information and the "unit" information from their respective tables
This will create a record in "occupations" that contains both the tenant and the unit information.
You can then add further information relevant to "occupation" if you so wish to that third table.

ohinrichs
Posts: 7
Joined: 2013-11-21 10:22

Re: many-to-many

Post by ohinrichs » 2014-07-04 08:10

Need to use a many-to-many relationship. Can't recreate a db-scheme like this:

Image

I always got an error:

Error checking:
Field 'tblOrderDetails.OrderID' cannot be a primary key and a foreign key at the same time.

How can i create a scheme like in the picture above? The OrderID-Field and all other relations must be autofilled with existing table contents.

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: many-to-many

Post by a.gneady » 2014-07-10 10:07

Use a separate primary key field, named for example "id" and set it to auto-increment .. you could also hide it from table view and detail view if you wish. After generating and uploading the application and setting it up, use phpMyAdmin to create a unique key on both "OrderId" and "ProductId" fields.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply