<p>Craft won't create the join table for you when specifying a MANY_MANY relationship.  You'll still need to manually create a record for that join table.  See Craft's own <code>craft/app/records/UserGroup_UserRecord.php</code> as an example.</p>

<p>What it will do, as <a href="https://craftcms.stackexchange.com/questions/1738/plugins-managing-related-records/1739#1739">mentioned in the answer you linked to</a> is keep the data up-to-date in the join table without having to specifically reference it in your queries.</p>

CC BY-SA 3.0
2015-04-26T18:18:57.880Z
2015-04-26T18:18:57.880Z
Brad Bell
<p>I replicated what was mentioned here: (<a href="https://craftcms.stackexchange.com/questions/1738/plugins-managing-related-records/1739#1739">Plugins: Managing Related Records</a>)</p>

<p>However I'm not seeing any new table created to on plugin install.</p>

<p>I have a "LeaderRecord" with</p>

<pre><code>'trips'     =&gt; [static::MANY_MANY, 'pluginexample_TripRecord', 'pluginexample_trip_leaders(tripId, leaderId)']
</code></pre>

<p>with the same relation defined in a "TripRecord", am I missing something to have the tabled created?</p>

<p>Thanks!</p>

CC BY-SA 3.0
2015-04-26T08:36:12.603Z
First – your record(s) _will only create tables when the plugin is first installed_, so if your plugin is already installed, you'll need to un- and reinstall it. Secondly, I believe your record's class name (second parameter) should be ```PluginExample_TripRecord```.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-26T08:49:43.790Z
I only used that name to obfuscate clients name - It is capitalized in actual. I have uninstalled and re-installed and still don't seem to be getting the PluginExample_trip_leaders table.
Dale Inverarity
CC BY-SA 3.0
2015-04-26T09:08:15.033Z
I might've misinterpreted your issue - both tables needs their own record. Simply defining relations in one record won't create another table.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-26T16:40:50.427Z
If you already have two record classes, I'd suggest adding them both – in full – to your question, it'll probably make figuring out your issue much easier.
Mats Mikkel Rummelhoff
<plugin-development><database>
MANY_MANY relationships in plugins
# MANY_MANY relationships in plugins

(Asked by: username_0 on 2015-04-26)

I replicated what was mentioned here: (Plugins: Managing Related Records)
However I'm not seeing any new table created to on plugin install.
I have a "LeaderRecord" with
'trips'     => [static::MANY_MANY, 'pluginexample_TripRecord', 'pluginexample_trip_leaders(tripId, leaderId)']

with the same relation defined in a "TripRecord", am I missing something to have the tabled created?
Thanks!

**Tags:** plugin-development, database
> **Comments:**
> **username_1**: First – your record(s) _will only create tables when the plugin is first installed_, so if your plugin is already installed, you'll need to un- and reinstall it. Secondly, I believe your record's class name (second parameter) should be ```PluginExample_TripRecord```.  
> **username_0**: I only used that name to obfuscate clients name - It is capitalized in actual. I have uninstalled and re-installed and still don't seem to be getting the PluginExample_trip_leaders table.  
> **username_1**: I might've misinterpreted your issue - both tables needs their own record. Simply defining relations in one record won't create another table.  
> **username_1**: If you already have two record classes, I'd suggest adding them both – in full – to your question, it'll probably make figuring out your issue much easier.  

---

## 1 answers

### Answer by username_2 on 2015-04-26. Score: 2 | Accepted answer

Craft won't create the join table for you when specifying a MANY\_MANY relationship. You'll still need to manually create a record for that join table. See Craft's own `craft/app/records/UserGroup_UserRecord.php` as an example.

What it will do, as [mentioned in the answer you linked to](https://craftcms.stackexchange.com/questions/1738/plugins-managing-related-records/1739#1739) is keep the data up-to-date in the join table without having to specifically reference it in your queries.


---

