-- Table: visual_element_reference
CREATE TABLE [visual_element_reference] (
    [gobject_id] int NOT NULL,
    [package_id] int NOT NULL,
    [mx_primitive_id] smallint NOT NULL,
    [visual_element_reference_index] int NOT NULL,
    [visual_element_bind_status] int NOT NULL,
    [is_relative_reference] char(1) NOT NULL,
    [checked_in_bound_visual_element_gobject_id] int NULL,
    [checked_in_bound_visual_element_package_id] int NULL,
    [checked_in_bound_visual_element_mx_primitive_id] smallint NULL,
    [checked_out_bound_visual_element_gobject_id] int NULL,
    [checked_out_bound_visual_element_package_id] int NULL,
    [checked_out_bound_visual_element_mx_primitive_id] smallint NULL,
    [unbound_timestamp] timestamp NOT NULL,
    [checked_in_unbound_visual_element_name] nvarchar(362) NULL,
    [checked_in_unbound_visual_element_type] nvarchar(32) NULL,
    [checked_in_unbound_tag_name] nvarchar(329) NULL,
    [checked_in_unbound_primitive_name] nvarchar(329) NULL,
    [checked_in_unbound_relative_object_name] nvarchar(329) NULL,
    [checked_in_unbound_visual_element_id] int NULL,
    [checked_out_unbound_visual_element_name] nvarchar(362) NULL,
    [checked_out_unbound_visual_element_type] nvarchar(32) NULL,
    [checked_out_unbound_tag_name] nvarchar(329) NULL,
    [checked_out_unbound_primitive_name] nvarchar(329) NULL,
    [checked_out_unbound_relative_object_name] nvarchar(329) NULL,
    [checked_out_unbound_visual_element_id] int NULL,
    [checked_out_visual_element_package_id] int NULL,
    [checked_out_visual_element_gobject_id] int NULL,
    [checked_out_to_user_guid] uniqueidentifier NULL,
    CONSTRAINT [PK_visual_element_reference] PRIMARY KEY ([gobject_id], [package_id], [mx_primitive_id], [visual_element_reference_index], [gobject_id], [mx_primitive_id], [package_id], [gobject_id], [mx_primitive_id], [package_id], [gobject_id], [mx_primitive_id], [package_id])
);
GO

ALTER TABLE [visual_element_reference] ADD FOREIGN KEY ([package_id]) REFERENCES [primitive_instance] ([package_id]);
GO

