Question: I am trying to create two tables in phpmyadmin: Users and Keys, the schema is as follows:

**Users**:

```
id int auto_incerement primary key

name varchar(50) not null

```

**Keys**:

```
user_id int

keys varchar(50) not null

```

Now I am running the following query to make the `user_id` in `Keys` a foreign key referencing the `id` in `Users`

```
ALTER TABLE Keys
FOREIGN KEY(user_id) REFERENCES Users(id)
ON UPDATE CASCADE
ON DELETE CASCADE

```

But after executing, i am getting the following error:

`#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Keys FOREIGN KEY(user_id) REFERENCES Users(id) ON UPDATE CASCADE ON DELETE CA' at line 1`

Can anyone tell me what am I doing wrong?

Thanks in advance.

Answer: 
`Keys` is a [reserved word](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) and must be encased in backticks:

```
ALTER TABLE `Keys`
ADD FOREIGN KEY (user_id) REFERENCES `Users` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE

```

It's best practice to encase all system related words in backticks.
You need to enclose keys with [back tick.](http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html) 

```
ALTER TABLE `Keys`

```