Page 1 of 1

Add to Muliple Tables

Posted: Mon Mar 23, 2009 5:44 pm
by cupaball
Hi All:

Here is my issue: I will have the following tables:

Venue:
ID | Name | Demographics


Venue Type:
ID | Title|


Venue by Type:
Venue ID | Venue Type ID

My question is if I have form used to enter enter a venue with muliplte venue types (check boxes), what is the theory behind adding adding info to the Venue by Type Table?

As it stands now, I only have 2 tables, Venue and Venue Type, but I can only have a one to one match.

Re: Add to Muliple Tables

Posted: Thu Mar 26, 2009 10:26 pm
by thinsoldier
This might not be the best way but it's how I do it.

If you're creating a new venue, after it's inserted grab it's id number (mysql has get_last_id mysql function or something)
then using that id add it and each selected venues to your venue by type table

Re: Add to Muliple Tables

Posted: Thu Mar 26, 2009 11:45 pm
by Christopher
You can also use what is called a Sequence to generate an ID to use as the key for all records. Some databases like Oracle and Postgres support Sequences, others like MySQL you need to emulate them with a table with an autoincrement column.

Re: Add to Muliple Tables

Posted: Sun Mar 29, 2009 1:00 pm
by josh
cupaball wrote:what is the theory behind adding adding info to the Venue by Type Table?
As it stands now, I only have 2 tables, Venue and Venue Type, but I can only have a one to one match.
Many to many associations are typically done with association tables