Rod
|
| Posted: 01/24/2003, 8:04 AM |
|
Hello,
I'm looking a way to implemet a M2M relation in my database in CC.
Can somebody showme the way?
|
|
|
 |
Will Jarvis
|
| Posted: 01/24/2003, 9:34 AM |
|
Let me guess. You are trying to add the junction record that ties the M2M together? I handled it by writting a function in the after insert event (I think....I'm not infront of my code) which queried the record(s) I just added (to get the keys...) and performed a insert SQL of the junction record. Getting the key was interesting as well. There is a article that defines a couple of slick methods of getting the last record in the event that your key is a auto increment field. In my case I had the key in a session variable so I was able to get it easily.
I am using ColdfusionMX with Access and SQL Server.
Hope this helps.....
|
|
|
 |
Rod
|
| Posted: 01/24/2003, 12:24 PM |
|
Will,
My question is about a many-to-many relationship allows for a multitude of
matching records in both tables involved. For example, there can be
many teachers in the teacher table who have many students in the
student table and vice-versa. In reality, this type of relationship
actually involves three tables, the third of which is a joint table that
carries the primary key from both tables. For example, the teacherID
and the studentID could be the primary keys of each table.
Can I buid a form in CC to manage this pattern?
|
|
|
 |
MI5
|
| Posted: 01/25/2003, 6:16 AM |
|
Well, this is actualy self-explaining, you have to make the third table which will connect the entries from the two others.
It might help to have the same column name for the same variable in all tables (ie student_id - in the main students table, and student_id in the binding table).
In the bookstore example wich is provided with the codecharge (examples) there is a nice example of this (tables: orders, books, users). Users and books are binded through the orders table.
Hope this helps.
|
|
|
 |
Rod
|
| Posted: 01/27/2003, 4:53 AM |
|
Tranks MI5...
|
|
|
 |
|