/* Table contains two data fields, a primary key constraint and a foreign key constraint    */
/* The constraints are designed to limit damage to data integrity in the event of           */ 
/* programmer error or other unforeseen circumstances.                                      */

/* Log book sections are a type of object hence the foreign key reference to objects and    */
/* should only occur with reference to specific log books hence foreign key reference to    */
/* that table.  There are also two references to the big_strings table                      */

CREATE TABLE log_books (
	log_book_id int NOT NULL ,
	log_flags int NOT NULL,
	CONSTRAINT PK_log_books PRIMARY KEY
	(
		log_book_id
	),
	CONSTRAINT FK_log_book_sec_to_res FOREIGN KEY
	(
		log_book_id
	) REFERENCES resources (
		resource_id
	)
)
GO

/* The rest of this SQL is deployment information  */


/* the value of type is any integer that isn't already in use for this installation of bodington  */
/* the value of super_type is the value for type given in the record for the Resource java class  */
/* db_name is not used in the bodington system, table_name is the name of the table use to store  */
/* these records and java_class is the class used to instantiate records in the Bodington System. */

INSERT INTO classes (type, super_type, db_name, table_name, java_class)
	VALUES(49, 10, null, 'log_books', 'org.bodington.logbook.server.LogBook')
GO

/* type is the type id used in the classes table, sequence is a number that indicates the order in */
/* which fields should be loaded and saved, field is the name of the field in the database table   */
/* set_method_name is the name of the method used to transfer the database field into the          */
/* instantiated java object, get_method_name is the method to transfer from java object to         */
/* database field, set_class_name and get_class_name are the java datatypes to use with these get  */
/* and set methods.  flags = 1 for the primary key field (which should be an int field )otherwise  */
/* flags = 0  The last three fields are for deprecated functionality and should be set to null.    */

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(49, 1, 'log_book_id', 'setLogBookId', 'getLogBookId', '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(49, 2, 'log_flags', 'setLogFlags', 'getLogFlags', 'int', 'int', 0, null, null, null )
GO




