CREATE TABLE aliases (
	alias_id int NOT NULL ,
	zone_id int NOT NULL ,
	alias_name varchar (64) NOT NULL ,
	alias_type int,
	user_category varchar (64),
	
	CONSTRAINT PK_aliases PRIMARY KEY
	(
		alias_id
	),
	CONSTRAINT FK_aliases_to_zones FOREIGN KEY
	(
		zone_id
	) REFERENCES zones (
		zone_id
	),
	CONSTRAINT FK_aliases_to_objects FOREIGN KEY
	(
		alias_id
	) REFERENCES objects (
		id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(8,	'building2', 'aliases', 'org.bodington.server.realm.Alias')
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(8, 1, 'alias_id', 'setAliasId', 'getAliasId', '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(8, 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(8, 3, 'alias_name', 'setAliasName', 'getAliasName', '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(8, 4, 'alias_type', 'setAliasType', 'getAliasType', '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(8, 5, 'user_category', 'setUserCategory', 'getUserCategory', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO



