This is my schema:
CREATE TABLE item (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
title varchar(60) NOT NULL,
description varchar(900) NOT NULL,
company_id integer NOT NULL REFERENCES company (id),
date datetime NOT NULL,
source_id integer NOT NULL REFERENCES source (id),
link varchar(255) NOT NULL,
location_id integer NOT NULL REFERENCES location (id)
);
CREATE TABLE location (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(255) NOT NULL,
coordinate varchar(255) NOT NULL,
location_id integer NOT NULL REFERENCES country (id)
);
CREATE TABLE country (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(255) NOT NULL
);
CREATE TABLE company (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(60) NOT NULL,
);
CREATE TABLE source (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(60) NOT NULL,
);
It is telling me that there is invalid syntax on line four on http://sqlfiddle.com when I put it in and click build schema. I can see no error, can anyone shed some light please?
Also if I have done anything poorly or made any bad decisions please let me know.
You have 2 faulty commas. One at the end of “CREATE TABLE company”, “CREATE TABLE source”.
And create country before location.