create table users ( uname varchar2(10) primary key, password varchar2(10) ); insert into users values('abc','abc'); insert into users values('def','d'); create table topics ( topicid number(5) primary key, topictitle varchar2(50), addedon date default sysdate, uname varchar2(10) references users(uname) ); insert into topics values(1001,'Programming Languages',sysdate,'abc'); insert into topics values(1002,'Web Frameworks',sysdate,'abc'); create sequence topicid_sequence start with 1010 nocache; create table questions (questionid number(5) primary key, questiontext varchar2(200) not null, opt1 varchar2(50) not null, opt2 varchar2(50) not null, opt3 varchar2(50) not null, topicid number(5) references topics(topicid) ); insert into questions values(2000,'What is your fav. dynamic Language','Javascript','Ruby','Python',1001); insert into questions values(2001,'What is your primary tool for writing code?','IDE','Text Editor','Both',1001); insert into questions values(2002,'Which MVC framework do you use?','JSF','Struts','Spring',1002); insert into questions values(2003,'Which Javascript library do you use?','JQuery','GWT','Others',1002); create sequence questionid_sequence start with 2010 nocache; create table answers_master ( surveyid number(5) primary key, topicid number(5) references topics(topicid) on delete cascade, takenon date ); insert into answers_master values (1,1001,sysdate); insert into answers_master values(2,1001,sysdate); insert into answers_master values(3,1002,sysdate); insert into answers_master values(4,1002,sysdate); create table answers_details ( surveyid number(5) references answers_master(surveyid) on delete cascade, questionid number(5) references questions(questionid), answer char(1), primary key(surveyid,questionid) ); insert into answers_details values(1,2000,1); insert into answers_details values(1,2001,1); insert into answers_details values(2,2000,1); insert into answers_details values(2,2001,2); insert into answers_details values(3,2002,2); insert into answers_details values(3,2003,1); insert into answers_details values(4,2002,1); insert into answers_details values(4,2003,3);