Jump to content

[SOLVED] columns with more than one variable


matthew_ellis24

Recommended Posts

Hi, I'm trying to set up a directory of habitat types, that also displays what species are found in association with them. I think I need my table to be set up like this:

habitat_id

habitat_name

habitat_description

habitat_countries

 

and then in the species table have a link to the habitat_id field.

 

There are a few problems, but I think they're essentially the same:

Species can occur in more than one habitat. So how do I enter that in the species table? Can I have 1, 2, 3 (for habitat ids) in the same column, or do I need to have multiple columns to allow for multiple number of habitats? And then the same problem with multiple countries having similar habitats. I'm just worried that if I have 1, 2, 3 and I search for "like 1" will I not then recall all the 10...19, 21...91 etc etc?

 

The ultimate goal being to allow a user to select:

- habitats, the countries it's found in and the species found in it

- countries and the habitats found in them

- species and the habitats it's found in

Doing the above should be easy once I'm certain of the database tables :D

 

thanks

Matt

Link to comment
Share on other sites

so I need to have something like this, where this is my habitat table:

<pre>

habitat_id    habitat_name                habitat_text

1             <i>Calluna-Erica</i> heath     <i>Calluna-Erica</i> heath consists of scrubby hea...

2             Deciduous Forest                 <i>Quercus</i> and <i>Fagus</i> etc etc

</pre>

 

and this is the table that relates habitats to species?

<pre>

habitat_species_id    habitat_id    species_id

1                             1                   9

2                             1                   37

3                             2                   37

4                             2                   1

</pre>

 

My only concern is this seems a pain to do anything with. For instance if I add a new habitat then I need to add it in the habitat table, and then add (in some instances) up to 200 new rows to the habitat_species table.

 

Then again, if it's the best way to do it, it's the best way to do it... :D

 

thanks for your help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.