CREATE TABLE user_details (
	user_detail_id int NOT NULL ,
	user_id int NOT NULL ,
	email_address varchar (64),
	dob int,
	
	CONSTRAINT PK_user_details PRIMARY KEY
	(
		user_detail_id
	),
	CONSTRAINT UQ_user_details_1 UNIQUE
	(
		user_id
	),
	CONSTRAINT FK_user_details_to_users FOREIGN KEY
	(
		user_id
	) REFERENCES users (
		user_id
	),
	CONSTRAINT FK_user_details_to_objects FOREIGN KEY
	(
		user_detail_id
	) REFERENCES objects (
		id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(16,	'building2', 'user_details', 'org.bodington.server.realm.UserDetail')
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(16, 1, 'user_detail_id', 'setUserDetailId', 'getUserDetailId', '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(16, 2, 'user_id', 'setUserId', 'getUserId', '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(16, 3, 'email_address', 'setEMailAddress', 'getEMailAddress', 'java.lang.String', 'java.lang.String', 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(16, 4, 'dob', 'setDob', 'getDob', 'java.lang.Integer', 'java.lang.Integer', 0, null, null, null )
GO



