CREATE TABLE groups (
	group_id int NOT NULL ,
	resource_id int NOT NULL,
	special_group int,
	name varchar (64) NOT NULL ,
	description varchar (128) NOT NULL,
	CONSTRAINT PK_groups PRIMARY KEY
	(
		group_id
	),
	CONSTRAINT FK_groups_to_resources FOREIGN KEY
	(
		resource_id
	) REFERENCES resources (
		resource_id
	),
	CONSTRAINT FK_groups_to_objects FOREIGN KEY
	(
		group_id
	) REFERENCES objects (
		id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(3,	'building2', 'groups', 'org.bodington.server.realm.Group')
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(3, 1, 'group_id', 'setGroupId', 'getGroupId', '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(3, 2, 'resource_id', 'setResourceId', 'getResourceId', '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(3, 3, 'special_group', 'setSpecialGroup', 'getSpecialGroup', 'java.lang.Integer', 'java.lang.Integer', 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(3, 4, 'name', 'setName', 'getName', '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(3, 5, 'description', 'setDescription', 'getDescription', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO


