
CREATE TABLE author(
aname VARCHAR(50) NOT NULL PRIMARY KEY
);

CREATE TABLE editor(
ename VARCHAR(50) NOT NULL PRIMARY KEY
);

CREATE TABLE school(
sname VARCHAR(50) NOT NULL PRIMARY KEY
);

CREATE TABLE publisher(
pname VARCHAR(50) NOT NULL PRIMARY KEY
);

CREATE TABLE article(
title VARCHAR(50) NOT NULL PRIMARY KEY,
pages VARCHAR(50),
cdrom VARCHAR(50),
month VARCHAR(50),
year  VARCHAR(50),
volume VARCHAR(50),
journal VARCHAR(50),
number VARCHAR(50),
url VARCHAR(50),
FOREIGN KEY (month) REFERENCES month (mname),
FOREIGN KEY (year) REFERENCES year (yname)
);


CREATE TABLE article_author(
title VARCHAR(50) NOT NULL,
aname VARCHAR(50) NOT NULL,
PRIMARY KEY (title,aname),
FOREIGN KEY (title) REFERENCES article (title),
FOREIGN KEY (aname) REFERENCES author (aname)
);

CREATE TABLE proceedings(
title VARCHAR(50) NOT NULL PRIMARY KEY,
year  VARCHAR(50),
isbn VARCHAR(50),
url VARCHAR(50),
FOREIGN KEY (year) REFERENCES year (yname)
);

CREATE TABLE proceedings_editor(
title VARCHAR(50) NOT NULL,
ename VARCHAR(50) NOT NULL,
PRIMARY KEY (title,ename),
FOREIGN KEY (title) REFERENCES proceedings (title),
FOREIGN KEY (ename) REFERENCES editor (ename)
);

CREATE TABLE inproceedings(
title VARCHAR(50) NOT NULL PRIMARY KEY,
pages VARCHAR(50),
booktitles VARCHAR(50),
month VARCHAR(50),
year  VARCHAR(50),
cdrom VARCHAR(50),
url VARCHAR(50),
FOREIGN KEY (month) REFERENCES month (mname),
FOREIGN KEY (booktitles) REFERENCES proceedings (title),
FOREIGN KEY (year) REFERENCES year (yname)
);


CREATE TABLE inproceedings_author(
title VARCHAR(50) NOT NULL,
aname VARCHAR(50) NOT NULL,
PRIMARY KEY (title,aname),
FOREIGN KEY (title) REFERENCES inproceedings (title),
FOREIGN KEY (aname) REFERENCES author (aname)
);


CREATE TABLE book(
title VARCHAR(50) NOT NULL PRIMARY KEY,
publisher VARCHAR(50),
cdrom VARCHAR(50),
year  VARCHAR(50),
isbn VARCHAR(50),
cite VARCHAR(50),
url VARCHAR(50),
FOREIGN KEY (publisher) REFERENCES publisher (pname),
FOREIGN KEY (year) REFERENCES year (yname)
);


CREATE TABLE book_author(
title VARCHAR(50) NOT NULL,
aname VARCHAR(50) NOT NULL,
PRIMARY KEY (title,aname),
FOREIGN KEY (title) REFERENCES book (title),
FOREIGN KEY (aname) REFERENCES author (aname)
);

CREATE TABLE book_editor(
title VARCHAR(50) NOT NULL,
ename VARCHAR(50) NOT NULL,
PRIMARY KEY (title,ename),
FOREIGN KEY (title) REFERENCES book (title),
FOREIGN KEY (ename) REFERENCES editor (ename)
);

CREATE TABLE masterthesis(
title VARCHAR(50) NOT NULL PRIMARY KEY,
year  VARCHAR(50),
school VARCHAR(50),
aname VARCHAR(50),
FOREIGN KEY (school) REFERENCES school (sname),
FOREIGN KEY (aname) REFRENCES author (aname),
FOREIGN KEY (year) REFERENCES year (yname)
);

CREATE TABLE phdthesis(
title VARCHAR(50) NOT NULL PRIMARY KEY,
aname VARCHAR(50),
year VARCHAR(50),
series VARCHAR(50),
number  VARCHAR(50),
month VARCHAR(50),
school VARCHAR(50),
publisher VARCHAR(50),
isbn VARCHAR(50),
FOREIGN KEY (month) REFERENCES month (mname),
FOREIGN KEY (aname) REFERENCES author (aname),
FOREIGN KEY (school) REFERENCES school (sname),
FOREIGN KEY (publisher) REFERENCES publisher (pname),
FOREIGN KEY (year) REFERENCES year (yname)
);


CREATE TABLE www(
title VARCHAR(50) NOT NULL PRIMARY KEY,
year  VARCHAR(50),
url VARCHAR(50),
FOREIGN KEY (year) REFERENCES year (yname)
);


CREATE TABLE month(
mname VARCHAR(50) NOT NULL PRIMARY KEY
);


CREATE TABLE year(
yname VARCHAR(50) NOT NULL PRIMARY KEY
);


CREATE TABLE article_inproceedings(
title VARCHAR(50) NOT NULL PRIMARY KEY,
inproceedings VARHAR(50),
FOREIGN KEY (inproceedings) REFERENCES proceedings_conference (title)
);

CREATE TABLE proceedings_conference(
title VARCHAR(50) NOT NULL PRIMARY KEY,
conference VARCHAR(50),
FOREIGN KEY (conference) REFERENCES conference (title)
);

CREATE TABLE conference(
title VARCHAR(50) NOT NULL PRIMARY KEY,
);

CREATE TABLE article_book(
title VARCHAR(50), 
aname VARCHAR(50), 
book VARCHAR(50),
PRIMARY KEY (title,aname,book),
FOREIGN KEY (title) REFERENCES article (title),
FOREIGN KEY (aname) REFERENCES author (aname),
FOREIGN KEY (book) REFERENCES book (title)
);
