CREATE TABLE questionnaire_responses (
    questionnaire_response_id int NOT NULL,
	questionnaire_result_id int NOT NULL,
	questionnaire_question_id int NOT NULL,
	comment_big_string_id int,
	item tinyint NOT NULL,
	CONSTRAINT PK_questionnaire_responses PRIMARY KEY
	(
		questionnaire_response_id
	),
	CONSTRAINT FK_q_response_to_objects FOREIGN KEY
	(
		questionnaire_response_id
	) REFERENCES objects (
		id
	),
	CONSTRAINT FK_q_response_to_results FOREIGN KEY
	(
		questionnaire_result_id
	) REFERENCES questionnaire_results (
		questionnaire_result_id
	),
	CONSTRAINT FK_q_response_to_questions FOREIGN KEY
	(
		questionnaire_question_id
	) REFERENCES questionnaire_questions (
		questionnaire_question_id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(40,	'building2', 'questionnaire_responses', 'org.bodington.assessment.QuestionnaireResponse')
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(40, 1, 'questionnaire_response_id', 'setQuestionnaireResponseId', 'getQuestionnaireResponseId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 1, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(40, 2, 'questionnaire_result_id', 'setQuestionnaireResultId', 'getQuestionnaireResultId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(40, 3, 'questionnaire_question_id', 'setQuestionnaireQuestionId', 'getQuestionnaireQuestionId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(40, 4, 'comment_big_string_id', 'setCommentBigStringId', 'getCommentBigStringId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(40, 5, 'item', 'setItem', 'getItem', 'byte', 'byte', 0, null, null, null )
GO

