Home > Archive > PHP SQL > November 2005 > Var to use in MySql
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Var to use in MySql
|
|
|
| Hi!
What kind of var should I use to store some words in a field?
For instance, I would like to save some key words for each user. How can
I achieve it?
USER KEY WORDS
john family,sports,basket,pete
lucas mirror,dog,soccer
I can't use SET var because the words can be different, defined by the user.
I have thought of using some fields such as KEYWORD1 KEYWORD2 KEYWORD3,
and store a string, but I don't want to limit the user.
Regards!
| |
| J.O. Aho 2005-11-24, 7:56 am |
| Harry wrote:
> Hi!
>
> What kind of var should I use to store some words in a field?
>
> For instance, I would like to save some key words for each user. How can
> I achieve it?
>
> USER KEY WORDS
> john family,sports,basket,pete
> lucas mirror,dog,soccer
>
> I can't use SET var because the words can be different, defined by the
> user.
>
> I have thought of using some fields such as KEYWORD1 KEYWORD2 KEYWORD3,
> and store a string, but I don't want to limit the user.
You can allow multiple rows for a user, each including one word as the
keyword, this way you won't limit the user and you will give a quite good many
possible keywords to use.
//Aho
| |
| IchBin 2005-11-24, 6:57 pm |
| Harry wrote:
> Hi!
>
> What kind of var should I use to store some words in a field?
>
> For instance, I would like to save some key words for each user. How can
> I achieve it?
>
> USER KEY WORDS
> john family,sports,basket,pete
> lucas mirror,dog,soccer
>
> I can't use SET var because the words can be different, defined by the
> user.
>
> I have thought of using some fields such as KEYWORD1 KEYWORD2 KEYWORD3,
> and store a string, but I don't want to limit the user.
>
> Regards!
Just create a separate table just for Keywords. Table would have these
rows..
- keyword_id, auto_increment
- user_foreign_key(FK), from the PK of your user table
- keyword
Have the primary key as keyword_id,user_foreign_key,keyword.
Also you can now add a constraint on this new keyword table to delete
all of the keywords/user when a user_id(PK) is deleted from your user
table. Example ..
CONSTRAINT cascadeDelete FOREIGN KEY( user_foreign_key ) REFERENCES
user_table( user_id ) ON DELETE CASCADE
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
________________________________________
__________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
|
|
|
|
|