This topic is locked
[SOLVED]

 Can PHPRunner generate Many-to-Many relationships?

2/27/2006 12:59:58
PHPRunner General questions
J
jme author

Can PHPRunner generate Many-to-Many relationships? I searched the forums but was not able to find any reference.
If it's possible, a simple 2 table example would put a big smile on my face!
Great product. Well worth the money. It can pay for itself the first day you use it.
-Julian

Sergey Kornilov admin 2/28/2006

Julian,
Generally PHPRunner doesn't offer many-to-many relationships, but you can try to set two master-detail relationships. Please see my example below:
There are two tables: Authors and Books. Each author can write one or more than one books and each book can be written one or more than one authors. The relationship between books and authors is Many-to-Many.

Set Authors as Master-table for Books and AuthorID as primary and foreign keys & set Books as Master-table for Authors and BookID as primary and foreign keys.

W
webbiz 3/2/2006

Hi Sergey,
Does your two table solution really work? Does it really account for both conditions of many books written by an author and many authors for a book?
Authors Table

=========

AuthorID (Primary Key)

Author
Books Table

========

BookID (Primary Key)

Book
AuthorsBooks Table (Method I)

=============

AuthorBookID

AuthorID (Foreign Key)

BookID (Foreign Key)
AuthorsBooks Table (Method II)

=============

AuthorID (Primary Foreign Key)

BookID (Primary Foreign Key)
Kindly let me know which of the above Methods should be used in your many-to-many solution. If the above table sets are wrong, kindly show us a possible table structure for it.
Should the Method II be used with a self lookup?

Sergey Kornilov admin 3/3/2006

Hi,
Your offered solution is rights. Both methods are correct.

But to use these methods you need to create new table, and it's not convenient for customers to use this new table which have a lot of records and contain only bookID and authorID. For example, if you want to find all authors of the book, you need to look through all records in the table.