DROP TABLE M_parts;
CREATE TABLE M_parts
(
	p_id		nchar(15) not null,
	p_name		nchar(10) NULL,
	p_desc		nvarchar(100) NULL,
	p_rev		nchar(6) NULL,
	p_planner	integer NULL,
	p_type		integer NULL,
	p_ind		integer NULL,
	p_lomark	integer NULL,
	p_himark	INTEGER NULL
)
ON M_PARTS_GROUP;

CREATE UNIQUE clustered INDEX M_parts_idx ON M_parts (p_id)
ON M_PARTS_GROUP;


DROP TABLE M_bom;
CREATE TABLE M_bom
(
	b_comp_id		nchar(15) not null,
	b_assembly_id		nchar(15) not null,
	b_line_no		integer NULL,
	b_qty			integer NULL,
	b_ops			integer NULL,	
	b_eng_change		nchar(10) NULL,	
	b_ops_desc		nvarchar(100) NULL
)
ON M_BOM_GROUP;

CREATE UNIQUE clustered INDEX M_bom_idx_c ON M_bom(b_assembly_id,b_comp_id,b_line_no)
ON M_BOM_GROUP;


DROP TABLE M_workorder;
CREATE TABLE M_workorder
(
	wo_number		integer not null,
	wo_o_id			integer NULL,
	wo_ol_id		integer NULL,
	wo_status		integer NULL,
	wo_assembly_id		nchar(15) NULL,
	wo_orig_qty		integer NULL,
	wo_comp_qty		integer NULL,
	wo_due_date		datetime NULL,
	wo_start_date		datetime NULL
)
ON M_WO_GROUP


CREATE UNIQUE clustered INDEX M_wo_idx ON M_workorder (wo_number)
ON M_WO_GROUP

DROP TABLE M_largeorder;
CREATE TABLE M_largeorder
(
	lo_id		integer not null,
	lo_o_id		integer NULL,
	lo_ol_id	integer NULL,
	lo_assembly_id	nchar(15) NULL,
	lo_qty		integer NULL,
	lo_due_date	datetime NULL
)
ON M_LARGORDER_GROUP;

CREATE UNIQUE clustered INDEX [M_lo_idx] ON M_largeorder ([lo_id])
ON [M_LARGORDER_GROUP]
CREATE UNIQUE INDEX [m_ol_o_idx] ON M_largeorder ([lo_o_id], [lo_ol_id])
ON [M_LARGORDER_GROUP]

DROP TABLE M_inventory;
CREATE TABLE M_inventory
(
	in_p_id		nchar(15) not null,
	in_qty		integer NULL,
	in_ordered	integer NULL,
	in_location	nchar(20) NULL,	
	in_acc_code	integer NULL,
	in_act_date	datetime NULL
)
ON M_INV_GROUP;

CREATE UNIQUE clustered INDEX M_inv_c ON M_inventory( in_p_id )
ON M_INV_GROUP;

