Var to use in MySql
am 24.11.2005 13:57:33 von harry
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!
Re: Var to use in MySql
am 24.11.2005 14:27:33 von Shion
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
Re: Var to use in MySql
am 24.11.2005 17:15:38 von IchBin
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-)