Question: Trying to create a table with a foreign key. I keep getting `ORA-00904` error. What am I doing wrong. Is it because table of the foreign key is not yet created ?

```
CREATE TABLE ingredients( 
   ingredient_id       number(2,0),
   ingredient          VARCHAR2(55) NOT NULL,
   quantity_required   VARCHAR2(15) NOT NULL,
   optional_ingredient VARCHAR2(30) NOT NULL,
   CONSTRAINT pk_ingr_id PRIMARY KEY(ingredient_id),
   CONSTRAINT fk_ingredient_list FOREIGN KEY(id) REFERENCES ingredient_list(id)
);

```

Answer: 
Take a look at the following line:

```
CONSTRAINT fk_ingredient_list FOREIGN KEY(id) REFERENCES ingredient_list(id)

```

Your table has no column named "id". I assume you meant to write

```
CONSTRAINT fk_ingredient_list FOREIGN KEY(ingredient_id) REFERENCES ingredient_list(id)

```

EDIT:  

Additionally, as you suspected yourself, if you want to reference the `ingredient_list` table, you must create it before creating the `ingredients` table that references it.
In my case I had used quotes in the table creation like below:

```
CREATE TABLE MY_TABLE (
"ID"                   NUMBER(19, 0) NOT NULL ENABLE,
"OPT_LOCK_VERSION"     NUMBER(19, 0),
-- etc.

```

And then tried creating similar constraint as in the question. That resulted to the same ORA-00904 error. When I modified my table creation script by removing those unnecessary quotes, the constraint creation started to work.