I have some basic questions that are driving me nuts, and I can't find
answers anywhere. I've been banging my head against the wall for hours and
hours. I've searched everywhere on the internet and looked in every book I
own. I can't find the information. Here are my questions.

In the CREATE TABLE statement, there are options to create keys and indexes,
and this is where I'm confused. I'll try to be as clear as possible in my
questions because I'm really desperate for help.

1. What is the difference between a KEY and an INDEX? These are two separate
options:

KEY [index_name] (index_col_name,...)
INDEX [index_name] (index_col_name,...)

I think the difference can't be uniqueness because UNIQUE is also an option:

UNIQUE [INDEX] [index_name] (index_col_name,...)

2. In the UNIQUE option above and in the FULLTEXT option, one of the
optional parameters is [INDEX]. What does this mean? How is the option
different if the word "INDEX" is included?

3. Dreamweaver generated some MySQL code that looked like this:

PRIMARY KEY (CustID)
KEY PRIMARY_KEY (CustID)

What is the point of the second option--the KEY statement? Why create two
keys on the same column? Is the KEY option necessary if you use the PRIMARY
KEY option?

4. How do you use an index or key? If you use the column on which the
key/index is based (are these terms interchangeable??), does MySQL use the
index?? Using the above example, do I have to use the names PRIMARY or
PRIMARY_KEY to use the indexed version of CustID? If I do a join using
CustID, is MySQL reading the table sequentially and bypassing the index
file?

5. There are two other options in the CREATE TABLE statement that I don't
understand at all:

[CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name, ...)
[reference_definition]
CHECK (expr)

My tables have foreign keys in them. Does that mean I need this FOREIGN KEY
statement? If so, then how do I use it? What is the CONSTRAINT parameter?
What is "symbol"? What is "reference_definition"?

And finally, what is "CHECK (expr)"? The mysql.com manual lists these
without any explanation or examples.

Thank you hugely and VASTLY in advance if you can clear up these issues for
me.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to