CREATE TABLE users (
	user_id int NOT NULL ,
	zone_id int NOT NULL ,
	name varchar (64) NOT NULL ,
	surname varchar (64) NOT NULL ,
	initials varchar (8) NOT NULL ,
	special_groups_a int NOT NULL,
	special_groups_b int NOT NULL,
	special_groups_c int NOT NULL,
	special_groups_d int NOT NULL,
	CONSTRAINT PK_users PRIMARY KEY
	(
		user_id
	),
	CONSTRAINT FK_users_to_zones FOREIGN KEY
	(
		zone_id
	) REFERENCES zones (
		zone_id
	),
	CONSTRAINT FK_users_to_objects FOREIGN KEY
	(
		user_id
	) REFERENCES objects (
		id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(1,	'building2', 'users', 'org.bodington.server.realm.User')
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(1, 1, 'user_id', 'setUserId', 'getUserId', '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(1, 2, 'zone_id', 'setZoneId', 'getZoneId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 2, 7, 'setZone', 'getZone' )
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(1, 3, '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(1, 4, 'surname', 'setSurname', 'getSurname', '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(1, 5, 'initials', 'setInitials', 'getInitials', '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(1, 6, 'special_groups_a', 'setSpecialGroupsA', 'getSpecialGroupsA', 'int', 'int', 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(1, 7, 'special_groups_b', 'setSpecialGroupsB', 'getSpecialGroupsB', 'int', 'int', 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(1, 8, 'special_groups_c', 'setSpecialGroupsC', 'getSpecialGroupsC', 'int', 'int', 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(1, 9, 'special_groups_d', 'setSpecialGroupsD', 'getSpecialGroupsD', 'int', 'int', 0, null, null, null )
GO


