Goofy wrote:
hi all,
i have to create a spelling and a picture game where words will be stored
in database. for the spelling game, the word wil be splited in two
parts.in the database the will be two columns the first syllabe and the
ending syllabe column. i was wondering what type except of type varchar
should be. should be primary or foreign key? i have decided to use php for
that game as i am familar with. is this the best language for that system?
Thanks
Hi Goofy,
Forgive me for being blunt, but your question gave me the impression you
need to learn some (SQL)basics first.
Try this for a SQL-primer (and learn about foreign keys, primary keys,
datatypes, etc):
http://www.w3schools.com
You will find in the left frame both a SQL and a PHP primer.
Be sure to to the SQL-lessons, they are really set up right and you will
learn the basics in just 1 day.
(I do not know if you need the PHP primer, up to you.)
Foreign keys are used to ensure database integrity and are used when you
reference a value from another table (often the Primary Key).
(In my humble opinion they should ALWAYS be used in that situation.)
As for the datatype (varchar), that depends on the database you will use.
Not all databases have the same datatypes.
In general: varchar is a good choice because the length is variable.
Only drawback is that it uses 16 bytes (in most cases I saw) to just store
nothing. 17 for 1 char, 18 for 2 chars, etc.
The reason is varchar uses 2 pointers to point to the beginning and the end
of the string, and (in most cases i saw) a pointer takes up 4 bytes.
So varchar can be a bit 'heavy' in certain cases, but do not worry about
that for now, just use it. :-)
Good luck Goofy, and drop back in here if you have questions.
Do you know which database you will use?
Regards,
Erwin Moller