CREATE TABLE metadata (
	metadatum_id int NOT NULL ,
	object_id int NOT NULL ,
	name VARCHAR(64) NOT NULL ,
	value LONG VARCHAR NOT NULL ,
	CONSTRAINT PK_metadata PRIMARY KEY
	(
		metadatum_id
	),
	CONSTRAINT UQ_metadata UNIQUE
	(
		object_id,
		name
	),
	CONSTRAINT FK_metadata_to_objects1 FOREIGN KEY
	(
		metadatum_id
	) REFERENCES objects (
		id
	),
	CONSTRAINT FK_metadata_to_objects2 FOREIGN KEY
	(
		object_id
	) REFERENCES objects (
		id
	)
)
GO


INSERT INTO classes (type, db_name, table_name, java_class)
	VALUES(48,	'building2', 'metadata', 'org.bodington.text.Metadatum')
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(48, 1, 'metadatum_id', 'setMetadatumId', 'getMetadatumId', '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(48, 2, 'object_id', 'setObjectId', 'getObjectId', '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(48, 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(48, 4, 'value', 'setValue', 'getValue', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO


