Page 1 of 1

many-to-many

Posted: 2014-05-28 17:00
by tloosle
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?

Re: many-to-many

Posted: 2014-05-28 17:43
by dssc
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.

Re: many-to-many

Posted: 2014-07-04 08:10
by ohinrichs
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.

Re: many-to-many

Posted: 2014-07-10 10:07
by a.gneady
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.