close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Switching from One-to-Many to Many-to-Many structure

Thread began 4/25/2014 8:47 am by iainmacdonald331081 | Last modified 4/25/2014 12:13 pm by Jason Byrnes | 163 views | 3 replies |

iainmacdonald331081

Switching from One-to-Many to Many-to-Many structure

I think I know what to do here, but just wanted to run it by to make sure I would be doing it correctly and not missing any tricks.

At the moment I have a One-to-Many structure:

tbl_Users
UserID (PK)
User
etc

tbl_Lodges
LodgeID (PK)
Lodge
UserID
etc

So any given Lodge has a single User associated, and that User can log in to an admin section and update the Lodge details.

We have increasingly found a need to allow multiple users to be able to log in and update these details, hence the switch to a many-to-many structure.

Am I right in thinking the way to do this is to create an interlinking table with the fields:

LodgeID
UserID

And the quickest way to create this table would just be to make a copy of the tbl_Lodges, delete all the fields other than LodgeID and UserID, and remove the PK from the UserID field?

One other question there - does the linking table need a third field to act as a Primary Key?

And lastly, in order to attach users to lodges would it just be a case of updating a two field form with the fields UserID and LodgeID? That's what I assume, although it involves looking up the lodge and user, noting the IDs and then adding a new record to the linking table. But wondered if I'm missing a trick there and there might be a more intuitive way of associating users with lodges?

Hope that makes sense.

Thank you!

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, you need a 3rd table to act as the linking table.

you should have 3 fields:
lodgeuserID - primary key
lodgeuserUserID - relates to the tbl_Users.UserID
lodgeusersLodgeID - relates to tbl_Lodges.LodgeID

I Would not copy an existing table, I Would just use your MySQL GUI Tool to create the new table and define the columns.

you should look into the manage relation table tutorial:
http://www.webassist.com/tutorials/Manage-relational-tables

Sign in to reply to this post

iainmacdonald331081

Thanks Jason - whether or not the linking table needed a PK was something I wasn't sure of.

With copying the table that was really because there are already lots of records in the Lodges table with a UserID. But if the linking table needs a PK that maybe won't be such a good plan.

Will also have a look at that tutorial.

Sign in to reply to this post

Jason ByrnesWebAssist

I neve like to copy tables, it seams like it should save time, but always ends up wasting it in creating bad data.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...