/***********************************************************************************
Name: Create_TRX_Tables
Desc :  Script creates ALL the tables requried for the ODS 
Version Rev: v0.6
Create Date: 15 Jan 2021
Version History:
		v0.1 -  Base Version	
		v0.5 -  ADDED IHT tables on 23rd March 2021  
		v0.6 - ADDED latest PTO file format changes 21st April 2021
		v0.7 - ADDED unique constraint comments
*************************************************************************************/

SET search_path To transactional;
drop table if exists test_master;

CREATE TABLE test_master (
	syspk serial NOT NULL, 			--	PK
	client_id SMALLINT NOT NULL, 	--	UKA1
	function_id SMALLINT NOT NULL,	--	UKA2
	Test_Name TEXT NOT NULL,		--	UKA3
	Test_Type TEXT NOT NULL,
	Test_Description TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);




drop table if exists test_lab_location_master;

CREATE TABLE test_lab_location_master (
	syspk serial NOT NULL,			--	PK
	client_id SMALLINT NOT NULL,	--	UKA1
	function_id SMALLINT NOT NULL,	--	UKA2
	Location_Name TEXT NOT NULL,	--	UKA3
	Soil_Type TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists test_instance;

CREATE TABLE test_instance (
	syspk serial  NOT NULL,			--	PK
	client_id SMALLINT NOT NULL,	--	UKA1
	function_id SMALLINT NOT NULL,	--	UKA2
	file_syspk INT ,			-- 	UKA3
	file_mnemonic TEXT,
	file_sheet_mnemonic TEXT , 	
	Test_master_Id INT ,
	test_file_name TEXT,
	project_name TEXT,
	Date_of_test date  ,
	Job_Order_No TEXT  NULL,
	Test_Tractor_ID INT NULL,
	Tractor_model TEXT,
	Tractor_make TEXT,
	Tractor_Sr_No TEXT,
	Generation TEXT,
	Test_Location_ID INT NULL,
	Test_Location_name TEXT,
	Test_mode TEXT,
	Test_Type TEXT,
	Test_Name TEXT,
	Test_condition TEXT,
	Objective_of_test TEXT,
	Background_of_test TEXT,
	Test_purpose TEXT,
	Test_Standard_Ref TEXT,
	Test_Standard_desc TEXT,
	Test_Standard_id INT,
	Acceptance_Criteria TEXT,
	Project_Group TEXT,
	Customer_Name TEXT,
	No_of_Sample TEXT,
	Sample_Receipt_Date date NULL,
	Test_Start_Date date NULL,
	Test_End_Date date NULL,
	Type_of_Soil TEXT,
	soil_Moisture_Content_pct NUMERIC NULL,
	Soil_Cone_Index NUMERIC NULL,
	soil_Bulk_Density_g_per_cc NUMERIC NULL,
	Field_Condition TEXT,
	Season TEXT,
	type_of_Road TEXT,
	Gradient_slope_1_Degree INT NULL,
	Gradient_slope_2_Degree INT NULL,
	tractor_Hitch_Type TEXT,
	Tractor_Hitch_Ht_mm INT NULL,
	Tractor_RWheel_C2H_dist_mm INT NULL,
	Test_Engineer TEXT,
	Test_Operator TEXT,
	Remarks TEXT,
	observations TEXT,
	Test_report_No TEXT,
	Test_Report_Date date NULL,
	Report_Title TEXT,
	Report_Prepared_By TEXT,
	Report_Reviewed_By TEXT,
	Report_Approved_by TEXT,
	Report_Prepared_date date,	
	report_reviewed_date date NULL,
	report_approved_date date NULL,
	Report_template_No TEXT,
	Report_template_Replaces TEXT,
	Report_template_Rev_No TEXT,
	Report_Template_Rev_Date TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;
/* This table is for future use */

drop table if exists test_instance_images;

CREATE TABLE test_instance_images (
	SYSPK  serial   NOT NULL,			--	PK	
	client_id  INT   NOT NULL,			--	UKA1
	function_id  INT   NOT NULL,		--	UKA2
	file_syspk  INT    NULL,  	-- UKA3
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT  ,			-- UKA4
	Srl_No INT  NULL,					-- 	UKA5
	image  bytea    NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

drop table if exists test_instance_tractor_info;

CREATE TABLE test_instance_tractor_info (
	syspk serial  NOT NULL,				--	PK
	client_id SMALLINT NOT NULL,		--	UKA1
	function_id SMALLINT NOT NULL,		--	UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_id INT   NULL,		--	UKA3
	Tractor_Model TEXT  NULL,			--	UKA4
	Tractor_Make TEXT ,
	Tractor_Sr_No TEXT,
	Tractor_Engine_HP INT NULL,
	Tractor_Platform TEXT,
	Configuration TEXT,
	Generation TEXT,
	Domestic_Export TEXT,
	Mahindra_Model_YN TEXT  NULL,
	Test_Tractor_YN TEXT  NULL,
	FIP_Type TEXT,
	Hour_Meter_Reading INT NULL,
	Steering_Type TEXT,
	Transmission_Type TEXT,
	Transmission_Disc_Diam TEXT,
	Wheel_Drive_Type TEXT NULL,
	Gear_Ratio NUMERIC NULL,
	EGR_YN TEXT,
	Brake_Type TEXT,
	Brake_Free_Play_LH INT NULL,
	Brake_Free_Play_RH INT NULL,
	PTO_Type TEXT,
	Standard_PTO_Speed_RPM INT NULL,
	EPTO_Speed_RPM TEXT NULL,
	PTO_Power_HP	NUMERIC,
	Ballast_Condition TEXT NULL,
	Ballasted_Tractor_Accessories TEXT NULL,
	Mechanical_Ballast_Rear TEXT NULL,
	Mechanical_Ballast_Rear_in_kg INT NULL,
	Water_Ballast_Rear_75_PCT TEXT NULL,
	Mechanical_Ballast_Front TEXT NULL,
	Mechanical_Ballast_Front_Kg INT NULL,  
	Front_bumper_weight_kg INT NULL,
	Total_Ballast_Weight INT NULL,
	Tractor_Weight_Front_kg INT NULL,
	Tractor_Weight_Rear_kg INT NULL,
	Tractor_Weight_Total_kg INT NULL,
	Tractor_Weight_Front_observed_kg INT NULL,
	Tractor_Weight_Rear_observed_kg INT NULL,
	Tractor_Weight_Total_observed_kg INT NULL,
	Tractor_Weight_Front_remark TEXT NULL,
	Tractor_Weight_Rear_remark TEXT NULL,
	Tractor_Weight_Total_remark TEXT NULL,
	Unballasted_Max_Speed_kmph NUMERIC NULL,
	Road_Ballasted_Max_speed_kmph NUMERIC NULL,
	Wheel_Base_mm INT NULL,
	Wheel_Track_mm INT,
	Overall_Height_mm INT,
	Rear_Track_WIdth_mm INT,
	Turning_Circle_Diameter_mm INT,
	Weight_reactions_front_kg INT,
	Weight_reactions_rear_kg INT,
	Hitch_Height_mm INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

drop table if exists test_instance_engine_info;

CREATE TABLE test_instance_engine_info (
	syspk serial NOT NULL,					--	PK	
	client_id SMALLINT NOT NULL,			--	UKA1
	function_id SMALLINT NOT NULL,			--	UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,				--	UKA3
	Test_instance_Tractor_ID INT   NULL,	--	UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Tractor_sr_no TEXT,
	Engine_Make TEXT,
	Engine_Type TEXT,
	Engine_Model TEXT,
	Engine_Serial_No TEXT,
	Low_Idle_Declared TEXT,
	Low_idle_Observed INT NULL,
	Low_Idle_remark TEXT NULL,
	High_Idle_Declared TEXT,
	High_idle_Observed INT NULL,
	High_Idle_remark TEXT NULL,
	Rated_RPM INT NULL,
	Rated_RPM_Observed INT NULL,
	Rated_RPM_remark TEXT NULL,
	Engine_set_RPM INT	NULL,
	Engine_Power_HP INT NULL,
	PTO_Power_HP INT NULL,
	Engine_to_PTO_Ratio_540_PTO TEXT NULL,
	Engine_to_PTO_Ratio_540E_PTO TEXT NULL,
	Engine_Cylinder_No INT NULL,
	Engine_Cylinder_Stroke_mm INT NULL,
	Engine_Cylinder_Bore_mm NUMERIC NULL,
	Engine_Cylinder_Capacity_ltr INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists test_instance_implement_info;

CREATE TABLE test_instance_implement_info (
	syspk serial  NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_ID INT   NULL,		-- UKA3
	Name_of_Implement TEXT  NULL,		-- UKA4
	Type_of_Implement TEXT,
	Make_of_Implement TEXT,
	No_of_Disc_blades_bottoms TEXT NULL,
	Type_of_disc_blades_bottoms TEXT,
	size_of_bottoms_blades_mm INT NULL,
	size_of_bottoms_blades2_mm INT,
	size_of_bottoms_blades3_mm INT,
	Spacing_of_bottoms_flanges_mm INT NULL,
	Cutting_Width_m TEXT,
	Implement_Weight_kg INT NULL,
	Hitch_Category TEXT,
	Span_For_Mounted_Implement_mm INT NULL,
	Mast_Height_For_Mounted_Implement_mm TEXT NULL,
	Type_of_Cage_wheel_HCW_FCW TEXT,
	Cage_wheel_Dia_mm INT NULL,
	Cage_wheel_width_mm INT NULL,
	Cage_Wheel_weight_kg  INT NULL,
	Cage_Wheel_Inner_ring_Dia_mm INT NULL,
	Cage_Wheel_Outer_ring_Dia_mm INT NULL,
	Cage_Wheel_center_ring_Dia_mm INT NULL,
	Dist_btwn_Fender_to_FCW_inner_ring_mm INT NULL,
	Dist_btwn_LHS_FCW_to_RHS_FCW_mm INT NULL,
	Dist_btwn_IW_ring_to_CW_mounting_ring_mm INT NULL,
	No_of_angles_on_cage_wheel INT NULL,
	No_of_days_of_water_logging INT NULL,
	Depth_of_water_mm INT NULL,
	Implement_Image_Ref_Id INT NULL,
	Length_mm INT NULL,
	Width_mm INT NULL,
	Height_mm INT NULL,
	Gross_mass_kg INT NULL,
	No_and_types_of_lugs TEXT NULL,
	Size_of_angle_section_mm INT NULL,
	Size_of_angle_section2_mm INT,
	Size_of_angle_section3_mm INT,
	Length_of_lugs_mm INT NULL,
	Spacing_of_lugs_mm INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

drop table if exists test_instance_trailer_info;

CREATE TABLE test_instance_trailer_info (
	syspk serial  NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1	
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_ID INT    NULL,		-- UKA3
	Type_Of_Trailer TEXT  NULL,			-- UKA4
	No_Of_Axle INT NULL,				-- UKA5
	No_Of_Wheels INT NULL,
	Trailer_Hitch_Ht_above_ground_lvl_mm INT NULL,
	Make_model_of_trailer TEXT,
	Trailer_platform_length_mm INT NULL,
	Trailer_platform_Width_mm INT NULL,
	Trailer_platform_Height_mm INT NULL,
	Tire_size TEXT,
	Inflation_pressure_psi INT NULL,
	Track_width_of_trailer_mm INT NULL,
	Hzntl_Dist_of_hitch_pt_from_trailer_face_mm INT NULL,
	Tractor_RWC_to_Hitch_Pt_Center_Dist_mm INT NULL,
	Dist_from_Trailer_front_axle_Dist_from_hitch_pt_mm INT NULL,
	Dist_from_tractor_RWC_to_trailer_RWC_mm INT NULL,
	Trailer_empty_Weight_Kg INT NULL,
	Trailer_Gross_Weight_Kg INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists  test_instance_tyre_info;

CREATE TABLE test_instance_tyre_info (
	syspk serial  NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_Instance_Tractor_ID INT   NULL,-- UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Tractor_sr_no TEXT,
	Tyre_Type TEXT  NULL,				-- UKA5
	Tyre_Make TEXT  NULL,
	Tyre_Size TEXT  NULL,
	tyre_use_type  TEXT NULL,
	Tyre_Ply_Rating INT NULL,
	tyre_Load_Carrying_Capacity TEXT,
	tyre_Pressure_psi NUMERIC NULL,
	tyre_Pressure_kg_per_cm2 NUMERIC NULL,
	tyre_Number_of_lug INT NULL,
	tyre_Number_of_no_load_lug_30m INT NULL,
	tyre_Lug_Height NUMERIC NULL,
	tyre_static_rolling_radius_mm NUMERIC NULL,
	tyre_Dynamic_rolling_radius_mm NUMERIC NULL,
	tyre_Wheel_Rim_Make_and_Size TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists test_instance_gear_speed_chart;

CREATE TABLE test_instance_gear_speed_chart (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		-- UKA4
    Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Tyre_condition TEXT  NULL,			-- UKA5
	Forward_Reverse TEXT  NULL,			-- UKA6
	Gear TEXT  NULL, 					-- UKA7
	speed_kmph NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists test_instance_tractor_info_misc;

CREATE TABLE test_instance_tractor_info_misc (
	syspk serial NOT NULL,					-- PK
	client_id SMALLINT NOT NULL,			-- UKA1
	function_id SMALLINT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
    file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,				-- UKA3
	Test_instance_Tractor_ID INT,			-- UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Capacity_of_fuel_tank_ltr  TEXT  NULL,	
	Make_type_and_model_of_injection_pump TEXT,
	Manufacturers_production_setting TEXT,
	Make_type_and_model_of_injectors TEXT,
	Make_type_and_model_of_magneto_coil_and_distributor TEXT,
	Make_type_and_model_of_carburetor TEXT,
	Ignition_or_injection_timing TEXT,
	Aircleaner_Make_model TEXT,
	Aircleaner_type TEXT,
	Precleaner_make_model TEXT,
	Precleaner_type TEXT, 
	Hydraulic_Type TEXT,
	Pump_speed_at_rated_engine_speed_rpm INT,
	Pump_HP INT,
	Oil TEXT,
	Lift_Rod_Type_LH TEXT,
	Lift_Rod_Type_RH TEXT,
	Lift_Rod_Length_LH INT,
	Lift_Rod_Length_RH INT,
	Lower_Link_Length_LH INT,
	Lower_Link_Length_RH INT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
drop table if exists test_instance_Wheels_info;

CREATE TABLE test_instance_Wheels_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		-- UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Steered_Driving_wheel TEXT,			-- UKA5
	Location_of_driving_wheel TEXT,
	Make_of_tyres TEXT,
	Wheel_Types TEXT,
	Wheel_Size TEXT,
	Maximum_permissible_load_kg NUMERIC,
	Ply_rating INT,
	Track_wIdth_max_mm INT,
	Track_wIdth_min_mm INT, 
	Inflation_pressure_kg_per_cm2 NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
drop table if exists test_instance_fuel_lubricant_info;
 
 CREATE TABLE test_instance_fuel_lubricant_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,			
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		-- UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	fuel_lubricant_unit TEXT,
	Trade_name TEXT,
	fuel_lubricant_Type TEXT,
	octane_per_Cetane_Number INT,
	Viscocity TEXT,
	Density_At_15C TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
drop table if exists  test_instance_equipment_info;
 
CREATE TABLE test_instance_equipment_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		-- UKA4
	Tractor_Model TEXT,
	Tractor_Make TEXT ,
	Srl_No	INT,						
	instrument_Name TEXT,				-- UKA5
	instrument_Serial_No TEXT,
	Calibration_Due_Date date,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
 drop table if exists  test_instance_measurement_uncertainty;
 
CREATE TABLE test_instance_measurement_uncertainty (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		
	Tractor_Model TEXT,
	Tractor_Make TEXT,
	Load_cell TEXT,		
	RPM_Meter TEXT,
	Speed TEXT,
	Fuel_flow_meter TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
drop table if exists  test_instance_atmospheric_info;
 
CREATE TABLE test_instance_atmospheric_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT,		
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,
	Tractor_Model TEXT,
	Tractor_Make TEXT,
	date_of_Test date,
	start_time TEXT,
	end_time TEXT,
	Ambient_temp_C NUMERIC,
	humidity_Pct NUMERIC,
	Pressure_kPa NUMERIC,
	wind_velocity_kmph TEXT,
	Background_Noise_dBA NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
drop table if exists  test_instance_drawbar_info;
 
CREATE TABLE test_instance_drawbar_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT NULL,			-- UKA3
	Test_instance_Tractor_ID INT,
	Tractor_Model TEXT,
	Tractor_Make TEXT, 
	Drawbar_type TEXT,
	Test_condition TEXT,
	Drawbar_type_name TEXT,				-- UKA4
	Drawbar_type_info TEXT,
	Height_above_ground_max_mm NUMERIC,
	Height_above_ground_min_mm NUMERIC,
	Position_related_to_PTO TEXT,
	Wheel_Base TEXT,
	Required_pull_in_kg NUMERIC,
	Actual_Pull_in_kg NUMERIC,
	Required_Power_in_hp NUMERIC,
	actual_power_in_hp NUMERIC,
	Calculated_hitch_height_mm NUMERIC,
	actual_hitch_height_mm NUMERIC,
	weight_Front_kg INT,
	weight_rear_kg INT,
	weight_total_kg INT,
	status TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
 
drop table if exists test_instance_weight_reaction;
 
 CREATE TABLE test_instance_weight_reaction (
	SYSPK serial NOT NULL,					-- PK
	Client_Id INT NOT NULL,					-- UKA1
	Function_Id INT NOT NULL,				-- UKA2
	file_syspk INT NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_Condition TEXT  NULL,			-- UKA4
	Total_Weight_kg INT NULL,
	High_Idle_RPM INT NULL,
	Front_Reaction_kg INT NULL,
	Rear_Reaction_kg INT NULL,
	Left_Reaction_FL_RL_kg INT NULL,
	Right_reaction_FR_RR_kg INT NULL,
	Front_Left_Reaction_kg INT NULL,
	Front_Right_Reactionkg INT NULL,
	Rear_Left_Reaction_kg INT NULL,
	Rear_Right_Reactionkg INT NULL,
	Distance_of_lifting_poINT_from_rear_axle_mm_d1 INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);
 
drop table if exists field_perf_summary;

CREATE TABLE field_perf_summary (
syspk Serial  NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_Instance_Tractor_ID INT NULL,	-- UKA4
	Tractor_Model TEXT  NULL,
	Tractor_Make TEXT ,
	Test_iteration_number INT   NULL,	-- UKA5
	Test_Condition TEXT NULL,
	Test_Date date   NULL,
	Engine_RPM_set INT NULL,
	PTO_RPM_set INT NULL,
	Gear_used TEXT,
	Nominal_Speed_KMPH NUMERIC NULL,
	Engine_RPM_Drop_on_straight_1st_Pass TEXT,
	Engine_RPM_Drop_on_straight_2nd_Pass TEXT,
	Engine_RPM_Drop_on_straight_3rd_Pass TEXT,
	Engine_RPM_Drop_on_turn_1st_Pass TEXT,
	Engine_RPM_Drop_on_turn_2nd_Pass TEXT,
	Engine_RPM_Drop_on_turn_3rd_Pass TEXT,
	No_of_passes INT NULL,
	Depth_of_cut_cm TEXT,
	erpmdrop_straight_1stpass_low numeric NULL,
	erpmdrop_straight_1stpass_high numeric NULL,
	erpmdrop_straight_2ndpass_low numeric NULL,
	erpmdrop_straight_2ndpass_high numeric NULL,
	erpmdrop_straight_3rdpass_low numeric NULL,
	erpmdrop_straight_3rdpass_high numeric NULL,
	erpmdrop_turn_1stpass_low numeric NULL,
	erpmdrop_turn_1stpass_high numeric NULL,
	erpmdrop_turn_2ndpass_low numeric NULL,
	erpmdrop_turn_2ndpass_high numeric NULL,
	erpmdrop_turn_3rdpass_low numeric NULL,
	erpmdrop_turn_3rdpass_high numeric NULL,
	depth_of_cut_cm_low numeric NULL,
	depth_of_cut_cm_high numeric NULL,
	Gear_used_on_Straight_Road TEXT,
	Straight_road_RPM_Drop TEXT,
	Gear_used_on_Up_Slope_1 TEXT,
	Up_Slope_RPM_Drop_1 TEXT,
	Gear_used_on_Up_Slope_2 TEXT,
	Up_Slope_RPM_Drop_2 TEXT,
	Gear_used_on_Down_Slope TEXT,
	Down_Slope_RPM_Shoot_up TEXT,
	Avg_speed_of_travel_kmph NUMERIC NULL,
	Total_dist_travelled_km NUMERIC NULL,
	No_load_speed_kmph NUMERIC NULL,
	On_load_speed_kmph NUMERIC NULL,
	Fuel_consumption_lit_per_hr NUMERIC NULL,
	Mileage_Km_per_Ltr NUMERIC NULL,
	Area_covered_acr_per_hr NUMERIC NULL,
	Fuel_consumption_lit_per_Acr NUMERIC NULL,
	Field_Efficiency_pct NUMERIC NULL,
	productivity numeric NULL,
	wheel_slippage_pct NUMERIC NULL,
	Fuel_consumption_Var_lit_per_hr NUMERIC NULL,
	Mileage_Var_Km_per_Ltr NUMERIC NULL,
	Area_covered_Var_acr_per_hr NUMERIC NULL,
	Fuel_consumption_Var_lit_per_Acr NUMERIC NULL,
	Fuel_consumption_Var_pct_lit_per_hr NUMERIC NULL,
	Mileage_var_pct_Km_per_Ltr NUMERIC NULL,
	Area_covered_Var_pct_acr_per_hr NUMERIC NULL,
	Fuel_consumption_Var_pct_lit_per_Acr NUMERIC NULL,
	Engine_Smoke_on_Load TEXT,
	Engine_acceleration_smoke TEXT,
	Range_Gear_Shifting TEXT,
	Speed_Gear_Shifting TEXT,
	Draft_Response TEXT,
	Tractor_Steer_ability TEXT,
	Tractor_braking_Perf TEXT,
	Front_Visibility TEXT,
	Implement_Accessibility TEXT,
	Front_Wheel_dragging_at_turning TEXT,
	Front_end_lifting_during_operation TEXT,
	RPM_Recovery_Time TEXT,
	Engine_Vibration TEXT,
	Engine_Sound TEXT,
	Implement_Lifting_per_Lowering_response TEXT,
	Pulverization_Quality TEXT,
	Pulverization_Index TEXT,
	test_engr_comments TEXT,
	test_mgr_comments TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

drop table if exists field_perf_summary_implement_info;

CREATE TABLE field_perf_summary_implement_info (
	syspk serial  NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL, 		
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT   NULL,		-- UKA3
	Name_of_implement TEXT  NULL,		-- UKA4
	Implement_Type TEXT,
	Implement_Size TEXT,
	Hitch_Category TEXT,
	Implement_Weight INT NULL,
	Type_of_Cage_Wheel TEXT,
	Cage_Wheel_Width_mm INT NULL,
	Cage_wheel_Weight INT NULL,
	Cage_Wheel_inner_and_Outer_Ring_Dia_mm INT NULL,
	Cage_Wheel_Center_Ring_Dia_mm INT NULL,
	Dist_between_RHS_and_LHS_cage_wheel_Inner_Ring_mm INT NULL,
	No_of_angles_on_cage_wheel INT NULL,
	Soil_Type TEXT,
	soil_Moisture_Content_pct NUMERIC NULL,
	soil_Bulk_Density_g_per_cc NUMERIC NULL,
	Soil_Cone_Index NUMERIC NULL,
	Field_Condition TEXT,
	Season TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

drop table if exists field_perf_summary_tractor_info;
CREATE TABLE field_perf_summary_tractor_info (
	syspk serial  NOT NULL,					-- PK
	client_id SMALLINT NOT NULL,			-- UKA1
	function_id SMALLINT NOT NULL,			-- UKA2
	file_syspk INT  NULL,		
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT   NULL,			-- UKA3
	Test_instance_Tractor_ID INT   NULL,	-- UKA4
	Tractor_Model TEXT  NULL,
	Tractor_Make TEXT,
	Tractor_Engine_HP INT NULL,
	Rated_RPM INT NULL,
	Transmission_Type TEXT,
	Wheel_Drive_Type TEXT NULL,
	FIP_Type TEXT,
	Steering_Type TEXT,
	Tractor_Weight_Front_kg INT NULL,
	Tractor_Weight_Rear_kg INT NULL,
	Tractor_Weight_Total_kg INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;

 DROP TABLE if exists field_perf_summary_trailer_info;

CREATE TABLE field_perf_summary_trailer_info (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,		
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT   NULL,		-- UKA3
	Trailer_type TEXT  NULL,			-- UKA4
	Tire_size_and_inflation_pressure_psi TEXT,
	No_Of_Axle INT NULL,
	No_Of_Wheels INT NULL,
	Trailer_Gross_Weight_Kg INT NULL,
	Tractor_RWC_to_Hitch_PoINT_Center_Dist_mm INT NULL,
	Tractor_Hitch_Ht_mm INT NULL,
	Trailer_hitch_Height_above_ground_level_mm INT NULL,
	Gradient_Slope_1_Degree INT NULL,
	Gradient_Slope_2_Degree INT NULL,
	Tractor_Hitch_Type TEXT NULL, 
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
) ;
 
  DROP TABLE if exists Drawbar_Perf_results_summary;
 
CREATE TABLE Drawbar_Perf_results_summary (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,		
	Tractor_Model TEXT,
	Tractor_Make TEXT,
	Gear_Number_and_Range TEXT  NULL,	-- UKA4
	Travel_Speed_Km_per_hr NUMERIC,		-- UKA5
	Drawbar_Power_kW NUMERIC,
	Drawbar_Power_hp NUMERIC,
	Drawbar_Pull_kgf INT,
	Drawbar_Pull_kN NUMERIC,
	Engine_speed_min_1 INT,
	Fan_Speed_min_1 INT,
	Wheel_Slip_Pct_Front NUMERIC,
	No_of_load_lugs_Front NUMERIC,
	Wheel_Slip_Pct_Rear NUMERIC,
	Fuel_Consumption_l_per_h NUMERIC,
	Fuel_Consumption_Kg_per_kWh NUMERIC,
	Fuel_Consumption_g_per_kWh NUMERIC,
	Fuel_Consumption_kWh_per_l NUMERIC,
	Temp_Engine_oil_C INT,
	Temp_Trans_Oil_C INT,
	Temp_Coolant_C INT,
	Temp_Fuel_In_C INT,
	Temp_Fuel_out_C INT,
	Atm_conditions_RH_Pct NUMERIC,
	Atm_conditions_Temp_C NUMERIC,
	Atm_conditions_Pressure_kPa NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
DROP TABLE if exists Drawbar_Perf_results;
 
CREATE TABLE Drawbar_Perf_results (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,
	Tractor_Model TEXT,
	Tractor_Make TEXT, 
	Gear_Number_and_Range TEXT  NULL,	-- UKA4
	Travel_Speed_Km_per_hr NUMERIC,		-- UKA5
	Drawbar_Power_kW NUMERIC,
	Drawbar_Power_hp NUMERIC,
	Drawbar_Pull_kgf INT,
	Drawbar_Pull_kN NUMERIC,
	Engine_speed_min_1 INT,
	Fan_Speed_min_1 INT,
	Wheel_Slip_Pct_Front NUMERIC,
	No_of_load_lugs_Front NUMERIC,
	Wheel_Slip_Pct_Rear NUMERIC,
	Fuel_Consumption_l_per_h NUMERIC,
	Fuel_Consumption_Kg_per_kWh NUMERIC,
	Fuel_Consumption_g_per_kWh NUMERIC,
	Fuel_Consumption_kWh_per_l NUMERIC,
	Temp_Engine_oil_C INT,
	Temp_Trans_Oil_C INT,
	Temp_Coolant_C INT,
	Temp_Fuel_In_C INT,
	Temp_Fuel_out_C INT,
	Atm_conditions_RH_Pct NUMERIC,
	Atm_conditions_Temp_C NUMERIC,
	Atm_conditions_Pressure_kPa NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );
 
DROP TABLE if exists Drawbar_Perf_OECD_results;
 
 CREATE TABLE Drawbar_Perf_OECD_results (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT NULL,		
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,
	Tractor_Model TEXT,
	Tractor_Make TEXT, 
	Test_Condition TEXT,				-- UKA4
	Srl_No TEXT,
	Gear_Number_and_Range TEXT,			-- UKA5
	Travel_Speed_Km_per_hr NUMERIC,		-- UKA6
	Drawbar_Power_kW NUMERIC,
	Drawbar_Power_hp NUMERIC,
	Drawbar_Pull_kgf INT,
	Drawbar_Pull_kN NUMERIC,
	Engine_speed_min_1 INT,
	Fan_Speed_min_1 INT,
	Wheel_Slip_Pct_Front NUMERIC,
	No_of_load_lugs_Front NUMERIC,
	Wheel_Slip_Pct_Rear NUMERIC,
	Fuel_Consumption_l_per_h NUMERIC,
	Fuel_Consumption_Kg_per_kWh NUMERIC,
	Fuel_Consumption_g_per_kWh NUMERIC,
	Fuel_Consumption_kWh_per_l NUMERIC,
	Temp_Engine_oil_C INT,
	Temp_Trans_Oil_C INT,
	Temp_Coolant_C INT,
	Temp_Fuel_In_C INT,
	Temp_Fuel_out_C INT,
	Atm_conditions_RH_Pct NUMERIC,
	Atm_conditions_Temp_C NUMERIC,
	Atm_conditions_Pressure_kPa NUMERIC,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );

DROP TABLE if exists Drawbar_Perf_observations;

 CREATE TABLE Drawbar_Perf_observations (
	syspk serial NOT NULL,				-- PK
	client_id SMALLINT NOT NULL,		-- UKA1
	function_id SMALLINT NOT NULL,		-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_ID INT  NULL,			-- UKA3
	Test_instance_Tractor_ID INT,
	Tractor_Model TEXT,
	Tractor_Make TEXT, 
	Srl_No INT  NULL,
	Test_Parameter TEXT,				-- UKA4
	Acceptance_Criteria TEXT,
	Observation TEXT,
	Remarks TEXT,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
 );

 DROP TABLE if exists PTO_Perf_results;

 CREATE TABLE PTO_Perf_results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT   NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_Mode TEXT NULL,					-- UKA4
	PTO_Test_Type  TEXT    NULL,			-- UKA5
	PTO_Test_sub_type TEXT NULL,			-- UKA6
	Serial_number  TEXT    NULL,
	Speed_Engine_rpm  INT    NULL,			-- UKA7
	Speed_PTO_rpm  NUMERIC   NULL,
	Brake_Torque_N_m  NUMERIC   NULL,
	Brake_Torque_Kg_m  NUMERIC   NULL,
	power_kw  NUMERIC   NULL,
	power_hp  NUMERIC   NULL,
	Eq_Cblock_row_number_Torque_Nm  NUMERIC   NULL,
	Fuel_Consumption_Kg_per_hr  NUMERIC   NULL,
	Fuel_Consumption_gm_per_hp_hr  NUMERIC   NULL,
	Fuel_Consumption_kg_per_kWh  NUMERIC   NULL,
	Fuel_Consumption_ltr_per_hr  NUMERIC   NULL,
	Fuel_Consumption_mm3_per_Str_Per_Cyl  NUMERIC   NULL,
	Sp_Energy_kwh_per_ltr  NUMERIC   NULL,
	Temperatures_Fuel_C  NUMERIC   NULL,
	Temperatures_Ambient_C  NUMERIC   NULL,
	Temperatures_Air_INTake_C  NUMERIC   NULL,
	Temperatures_Water_outlet_C  NUMERIC   NULL,
	Temperatures_Exhaust_C  NUMERIC   NULL,
	Temperatures_Engine_oil_C  NUMERIC   NULL,
	Pressure_Ambient_Bar  NUMERIC   NULL,
	Pressure_Ambient_mm_of_hg  NUMERIC   NULL,
	Pressure_Exhaust_Bar  NUMERIC   NULL,
	Pressure_Exhaust_mm_of_hg  NUMERIC   NULL,
	Pressure_Lub_oil_Bar  NUMERIC   NULL,
	Pressure_Lub_oil_mm_of_hg  NUMERIC   NULL,
	RH_pct  NUMERIC   NULL,
	Average_YN TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);


 DROP TABLE if exists PTO_Key_Perf_Parameters;

create table PTO_Key_Perf_Parameters (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Tractor_serial_number TEXT NULL,
	Tractor_Emission TEXT NULL,
	Test_standard TEXT NULL, -- ICT
	Test_Mode TEXT NULL, 					-- UKA4	(Standard, Normal, Boost, Eco)
	PTO_Gear_Ratio  NUMERIC   NULL,
	Specific_gravity_of_fuel_kg_per_m3  NUMERIC   NULL,
	PTO_Power_Declared_hp TEXT NULL,
	PTO_Power_Observed_hp NUMERIC NULL,
	PTO_Power_Declared_Kw TEXT NULL,
	PTO_Power_Observed_Kw NUMERIC NULL,
	PTO_SFC_Declared_gm_per_hp_hr TEXT NULL,
	PTO_SFC_Observed_gm_per_hp_hr NUMERIC NULL,
	PTO_SFC_Declared_kg_per_Kw_hr TEXT NULL,
	PTO_SFC_Observed_kg_per_Kw_hr NUMERIC NULL,
	pct_of_Backup_Torque_Declared TEXT NULL,
	pct_of_Backup_Torque_Observed NUMERIC NULL,
	Max_Equ_crankshaft_Torque_Declared_Nm TEXT NULL,
	Max_Equ_crankshaft_Torque_Observed_Nm NUMERIC NULL,
	Equ_crankshaft_Torque_at_Max_Power_Declared_Nm TEXT NULL,
	Equ_crankshaft_Torque_at_Max_Power_Observed_Nm NUMERIC NULL,
	Engine_speed_at_max_equ_crankshaft_torque_Declared_rpm TEXT NULL,
	Engine_speed_at_max_equ_crankshaft_torque_Observed_rpm NUMERIC NULL,
	Rated_Engine_Speed_Declared_rpm TEXT NULL,
	Rated_Engine_Speed_Observed_rpm NUMERIC NULL,
	Max_Torque_Engine_Speed_Declared_rpm TEXT NULL,
	Max_Torque_Engine_Speed_Observed_rpm NUMERIC NULL,
	Engine_High_Idle_Speed_Declared_rpm TEXT NULL,
	Engine_High_Idle_Speed_Observed_rpm NUMERIC NULL,
	Engine_Low_Idle_Speed_Declared_rpm TEXT NULL,
	Engine_Low_Idle_Speed_Observed_rpm NUMERIC NULL,
	Engine_Oil_Temp_at_NA_Declared_C TEXT NULL,
	Engine_Oil_Temp_at_NA_Observed_C NUMERIC NULL,
	Coolant_Temp_at_NA_Declared_C TEXT NULL,
	Coolant_Temp_at_NA_Observed_C NUMERIC NULL,
	Engine_Oil_Temp_at_HA_Declared_C TEXT NULL,
	Engine_Oil_Temp_at_HA_Observed_C NUMERIC NULL,
	Coolant_Temp_at_HA_Declared_C TEXT NULL,
	Coolant_Temp_at_HA_Observed_C NUMERIC NULL,
	Ambient_Pressure_Declared_Bar TEXT NULL,
	Ambient_Pressure_Observed_Bar NUMERIC NULL,
	Ambient_Pressure_Declared_mm_of_Hg TEXT NULL,
	Ambient_Pressure_Observed_mm_of_Hg NUMERIC NULL,
	Back_Pressure_Declared_Bar TEXT NULL,
	Back_Pressure_Observed_Bar NUMERIC NULL,
	Back_Pressure_Declared_mm_of_hg TEXT NULL,
	Back_Pressure_Observed_mm_of_hg NUMERIC NULL,
	Engine_Oil_Pressure_Declared_Bar TEXT NULL,
	Engine_Oil_Pressure_Observed_Bar NUMERIC NULL,
	Exhaust_Temp_Declared_C TEXT NULL,
	Exhaust_Temp_Observed_C NUMERIC NULL,
	Relative_Humidity_Declared_pct TEXT NULL,
	Relative_Humidity_Observed_pct NUMERIC NULL,
	Coolant_water_pct_of_total_coolant_capacity_Declared TEXT NULL,
	Coolant_water_pct_of_total_coolant_capacity_Observed NUMERIC NULL,
	Test_Engineer TEXT NULL,
	Test_Bed TEXT NULL,
	Location_name TEXT NULL,
	Total_Run_hrs INT NULL,
	Test_date date NULL,
	Tooled_up TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists PTO_smoke_Test;

create table PTO_smoke_Test (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_mode TEXT NULL,					-- UKA4
	PTO_Test_Type TEXT NULL,				-- UKA5
	Srl_no TEXT NULL,
	Engine_speed_rpm  INT NULL,		-- UKA6
	PTO_Speed_rpm  INT   NULL,
	Torque_100_pct  NUMERIC   NULL,
	Torque_80_pct  NUMERIC   NULL,
	Smoke_FSN_100_pct  NUMERIC   NULL,
	Smoke_FSN_80_pct  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists PTO_Engine_oil_consumption;

create table PTO_Engine_oil_consumption (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_mode TEXT NULL,					-- UKA4
	PTO_Test_Type TEXT NULL, 				-- UKA5
	Srl_No  TEXT   NULL,					-- UKA6
	Oil_Consumption_Gm_per_hr  NUMERIC   NULL,
	Oil_consumption_pct_of_Fuel_consumption  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists PTO_Multipoint_mapping;

Create table PTO_Multipoint_mapping (
	SYSPK  serial   NOT NULL, 					-- PK
	client_id  INT   NOT NULL, 					-- UKA1
	function_id  INT   NOT NULL,  				-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL, 				-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_mode TEXT NULL,  						-- UKA4
	Test_condition  TEXT    NULL, 				-- UKA5
	Engine_speed_rpm  INT    NULL,				-- UKA6
	Engine_load_pct  INT    NULL,  				-- UKA7
	SFC_gm_per_hp_hr  NUMERIC   NULL,
	Fuel_Consumption_ltr_per_hr  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
	);
	
DROP TABLE if exists PTO_Perf_Governing_Graph;

Create table PTO_Perf_Governing_Graph (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,			
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_mode TEXT NULL,  					-- UKA4
	Test_type TEXT NULL,
	Test_condition  TEXT    NULL,			-- UKA5
	Engine_Speed_rpm  INT    NULL,			-- UKA6
	Torque_Kg_m  NUMERIC   NULL,
	Power_hp  NUMERIC   NULL,
	SFC_gm_per_hp_hr  NUMERIC   NULL,
	Fuelling_mm3_per_stroke_per_cyl  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_PTO_Perf_Results_summary;

create table Budni_PTO_Perf_Results_summary (
	SYSPK  serial   NOT NULL,					-- PK
	client_id  INT   NOT NULL,					-- UKA1
	function_id  INT   NOT NULL,				-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,				-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	PTO_Category  TEXT    NULL,					-- UKA4
	PTO_Sub_Category  TEXT    NULL,				-- UKA5
	Power_kW  NUMERIC   NULL,
	Speed_rpm_PTO  INT   NULL,
	Speed_rpm_Engine  INT   NULL,
	Fuel_Consumption_ltr_per_hr  NUMERIC   NULL,
	Fuel_Consumption_kg_per_hr  NUMERIC   NULL,
	specific_kg_per_kWh  NUMERIC   NULL,
	Specific_Energy_kWhl  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_PTO_Perf_Results_Details;

create table Budni_PTO_Perf_Results_Details (
	SYSPK  serial   NOT NULL,					-- PK		
	client_id  INT   NOT NULL,					-- UKA1
	function_id  INT   NOT NULL,				-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,				-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Ambient_type  TEXT    NULL,					-- UKA4
	No_load_max_engine_speed_rpm  INT   NULL,
	equi_crankshaft_torque_at_max_power_Nm  NUMERIC   NULL,
	max_equi_crankshaft_torque_Nm  INT   NULL,
	Engine_speed_at_max_equi_crankshaft_torque_rpm  NUMERIC   NULL,
	Backup_torque  TEXT   NULL,
	Pct_Smoke_level_max_light_absorption_coef_per_mtr  NUMERIC   NULL,
	Range_of_atm_conditions_Temp_C  TEXT   NULL,
	Range_of_atm_conditions_Pressure_kPa  TEXT   NULL,
	Range_of_atm_conditions_Rel_HumIdity_Pct  TEXT   NULL,
	max_temp_Engine_Oil_C  INT   NULL,
	max_temp_Coolant_water_C  INT   NULL,
	max_temp_Fuel_c  INT   NULL,
	max_temp_Air_INTake_C  TEXT   NULL,
	max_temp_Exhaust_Gas_C  INT   NULL,
	Pressure_at_max_Power_INTake_Air_kPa  TEXT   NULL,
	Pressure_at_max_Power_Exhst_gas_bfr_turbo_charger_kPa  TEXT   NULL,
	Consumptions_Lub_oil_gkWh  NUMERIC   NULL,
	Consumptions_coolant_Water_Pct_of_total_coolant_capacity  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Drawbar_Perf_Results;

create table Budni_Drawbar_Perf_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,	
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_Condtion  TEXT    NULL,			-- UKA4		
	Gear_Used  TEXT    NULL,				-- UKA5
	Travel_speed_km_per_hr NUMERIC NULL, 
	Drawbar_Power_kW  NUMERIC   NULL,
	Drawbar_Pull_kN  NUMERIC   NULL,
	Engine_speed_rpm  INT   NULL,
	Wheel_Slippage_Pct  NUMERIC   NULL,
	Fuel_Consumption_Kg_per_kWh  NUMERIC   NULL,
	Fuel_consumption_ltr_per_hr NUMERIC NULL,
	specific_energy_kwh_per_ltr  NUMERIC   NULL,
	Temp_Fuel_C  TEXT   NULL,
	Temp_trans_oil_C TEXT NULL,
	Temp_Coolant_C  TEXT   NULL,
	Temp_Engine_oil_C  TEXT   NULL,
	Atmosp_conditions_RH_Pct  TEXT   NULL,
	Atmosp_conditions_Temp_C  TEXT   NULL,
	Atmosp_conditions_Pressure_kPa  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_Hydraulic_Power_test_Results;

create table Budni_Hydraulic_Power_test_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Pump_dlvry_rate_at_min_pressure_engine_speed_l_per_min  NUMERIC   NULL,
	Max_hydraulic_power_kW  NUMERIC   NULL,
	Pump_dlvry_rate_at_Max_hydraulic_power_lmin  NUMERIC   NULL,
	Pressure_at_Max_hydraulic_power_MPa  NUMERIC   NULL,
	Sustained_pressure_of_the_open_relief_valve_Mpa  NUMERIC   NULL,
	tapping_poINT_Relief_valve_test  TEXT   NULL,
	tapping_PoINT_Pump_perf_test  TEXT   NULL,
	tapping_PoINT_Temperature_of_hydraulic_fluId_C  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Hydraulic_Lifting_Capacity_test_Results;

create table Budni_Hydraulic_Lifting_Capacity_test_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_condition  TEXT   NULL,			-- UKA4
	Height_of_lower_hitch_pt_above_ground_in_down_position_mm  INT   NULL,
	Vertical_move_ment_with_lifting_forces_mm  INT   NULL,
	Max_force_exerted_through_full_range_kN  NUMERIC   NULL,
	Corresponding_pressure_MPa  INT   NULL,
	Moment_about_rear_axle_kN_m  NUMERIC   NULL,
	Max_tilt_angle_of_mast_from_vertical_degrees  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Hydraulic_Maint_of_lift_Load_Results;

create table Budni_Hydraulic_Maint_of_lift_Load_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Elapsed_time_min  INT   NULL,			-- UKA4
	Force_applied_at_the_frame_kN  NUMERIC   NULL,
	Temp_of_hydraulic_fluid_at_the_start_of_test_C  TEXT   NULL,
	Cumulative_drop_in_height_of_lift_mm  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Brake_Perf_Service_Brake_Test_Results;

create table Budni_Brake_Perf_Service_Brake_Test_Results (
	SYSPK  serial   NOT NULL,				-- PK			
	client_id  INT   NOT NULL,				-- UKA1		
	function_id  INT   NOT NULL,			-- UKA2	
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3		
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Brake_Test_Type  TEXT    NULL,			-- UKA4
	Brake_Test_Name  TEXT    NULL,			-- UKA5
	Speed_condition  TEXT    NULL,			-- UKA6
	Ballast_Condition  TEXT    NULL,		-- UKA7
	Trial_number  INT    NULL,				-- UKA8
	Braking_device_control_force_N  INT   NULL,
	Mean_deceleration_msec2  NUMERIC   NULL,
	Stopping_Dist_m  NUMERIC   NULL,
	Max_dev_of_tractor_from_its_org_course_m  TEXT   NULL,
	Abnormal_vibration  TEXT   NULL,
	The_brakes_were_heated_by  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Brake_Perf_Parking_Brake_Test_Results;

create table Budni_Brake_Perf_Parking_Brake_Test_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Test_condition  TEXT   NULL,			-- UKA4
	Braking_device_control_force_N_Facing_up  INT   NULL,
	Efficacy_of_parking_brake_Facing_up  TEXT   NULL,
	Braking_device_control_force_N_Facing_down  INT   NULL,
	Efficacy_of_parking_brake_Facing_down  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_Noise_Atmospheric_conditions;

create table Budni_Noise_Atmospheric_conditions(
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Noise_position  TEXT    NULL,			-- UKA4
	Background_noise_level_dBA  INT   NULL,
	Temperature_C  INT   NULL,
	Pressure_kPa  NUMERIC   NULL,
	Relative_humIdity_Pct  INT   NULL,
	Wind_velocity_ms  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_Noise_Measurement_Results;

create table Budni_Noise_Measurement_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Noise_position  TEXT    NULL,			-- UKA4
	Gear  TEXT    NULL,						-- UKA5
	Drawbar_pull_max_noise_kN  TEXT   NULL,
	Travel_speed_km_per_hr TEXT   NULL,
	Noise_level_dB_A  NUMERIC   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Vibration_Measurement;

create table Budni_Vibration_Measurement (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Srl_No  INT    NULL,
	Measuring_Points  TEXT    NULL,			-- UKA4
	Vibration_At_no_load_VD_microns INT NULL,
	Vibration_At_no_load_HD_microns INT NULL,
	Vibration_At_load_85_Pct_of_max_PTO_Power_VD_microns INT NULL,
	Vibration_At_load_85_Pct_of_max_PTO_Power_HD_microns INT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Centre_of_Gravity_Location;

create table Budni_Centre_of_Gravity_Location (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	condition  TEXT    NULL,				-- UKA4
	Particulars  TEXT    NULL,				-- UKA5
	coordinates  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Field_Perf_Results;

create table Budni_Field_Perf_Results (
	SYSPK serial NOT NULL,					-- PK
	Client_Id INT NOT NULL,					-- UKA1
	Function_Id INT NOT NULL,				-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,				-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Operation_type TEXT  NULL,				-- UKA4
	Type_of_soil TEXT NULL,
	Avg_soil_moisture_pct_ TEXT NULL,
	Avg_depth_of_standing_water_cm TEXT NULL,
	Bulk_density_of_soil_g_per_cc TEXT NULL,
	Cone_index_kgf_per_sq_cm TEXT NULL,
	Puddling_index_pct TEXT NULL,
	Gear_used TEXT NULL,
	Avg_speed_of_operation_kmph TEXT NULL,
	Avg_wheel_slip_pct TEXT NULL,
	Avg_Travel_reduction_pct TEXT NULL,
	Avg_depth_of_cut_cm TEXT NULL,
	Avg_Depth_of_puddle_cm TEXT NULL,
	Avg_working_width_cm TEXT NULL,
	Area_covered_ha_per_hr TEXT NULL,
	Fuel_consumption_ltr_per_hr TEXT NULL,
	Fuel_consumption_ltr_per_ha TEXT NULL,
	Avg_draft_of_implement_kN TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists Budni_Haulage_Perf_Results;

create table Budni_Haulage_Perf_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,	
	Trailer_type  TEXT    NULL,				-- UKA4
	Gross_mass_of_trailer_tonne  INT   NULL,
	Height_of_trailer_hitch_above_ground_level_mm  INT   NULL,
	Gear_used_negotiating_slopes_up_to_8Pct  TEXT   NULL,	
	Avg_travel_speed_kmph  TEXT   NULL,
	Avg_fuel_consumption_ltr_per_hr  TEXT   NULL,
	Avg_fuel_consumption_ml_per_km_per_tonne  TEXT   NULL,
	Avg_Dist_traveled_per_litre_of_fuel_consumption_km  TEXT   NULL,
	Effectiveness_of_Brakes  TEXT   NULL,
	Maneuverability_of_tractor_trailer_combination  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Air_Cleaner_Perf_Results;

create table Budni_Air_Cleaner_Perf_Results (
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	Sequence_Number  INT    NULL,			-- UKA4
	Atm_Condtion_temperature_C  TEXT   NULL,
	Atm_Condition_Pressure_kPa  TEXT   NULL,
	Atm_Condition_Relative_humIdity_Pct  NUMERIC   NULL,
	Atm_condtion_mass_of_oil_before_test  NUMERIC   NULL,
	Position_of_tractor  TEXT   NULL,
	Loss_of_oil_g  NUMERIC   NULL,
	Oil_pull_Over_Pct  NUMERIC   NULL,
	Engine_oil_pressure  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists Budni_Test_observations;


create table Budni_Test_observations(
	SYSPK  serial   NOT NULL,				-- PK
	client_id  INT   NOT NULL,				-- UKA1
	function_id  INT   NOT NULL,			-- UKA2
	file_syspk  INT    NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_instance_Id  INT    NULL,			-- UKA3
	Test_instance_Tractor_Id  INT   NULL,
	Tractor_Model  TEXT   NULL,
	Tractor_Make  TEXT   NULL,
	sequence_number INT  NULL,				-- UKA4
	Srl_No  TEXT    NULL,
	Characteristic  TEXT    NULL,
	Category_Evaluative_or_Non_Evaluative  TEXT   NULL,
	Requirements_as_per_IS_12207_2008  TEXT   NULL,
	Values_declared_by_the_applicant_D_Rqmt  TEXT   NULL,
	As_observed  TEXT   NULL,
	Whether_meets_the_requirements_YN  TEXT   NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_CGM_Lifting_Angle_Load_Details;

CREATE TABLE IHT_CGM_Lifting_Angle_Load_Details (
	SYSPK serial NOT NULL,				-- PK				
	Client_Id INT NOT NULL,				-- UKA1				
	Function_Id INT NOT NULL,			-- UKA2			
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3			
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Angle NUMERIC NULL,					-- UKA4
	Value_in_tan NUMERIC NULL,
	Diff_Of_tan_value NUMERIC NULL,
	Load_kn NUMERIC NULL,
	Load_kg NUMERIC NULL,
	Diff_in_Load_kg NUMERIC NULL,
	Vertical_Co_Ordinate_Z_mm NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists IHT_CGM_Results;

CREATE TABLE IHT_CGM_Results (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Horizontal_Distance_from_RAC_X_mm NUMERIC NULL,
	Lateral_Co_Ordinate_in_Horizontal_Plane_Y_mm NUMERIC NULL,
	Vertical_Co_Ordinate_Z_mm NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists IHT_Steering_Effort;

CREATE TABLE IHT_Steering_Effort (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_condition TEXT NULL,			-- UKA4
	Test_Speed_kmph TEXT NULL,			-- UKA5
	Max_Angle_LH NUMERIC NULL,
	Max_Angle_RH NUMERIC NULL,
	Max_Effort_LH NUMERIC NULL,
	Max_Effort_RH NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

 DROP TABLE if exists IHT_Steering_Effort_Raw_Data;

CREATE TABLE IHT_Steering_Effort_Raw_Data (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	time_sec NUMERIC NULL,				-- UKA4
	steering_anglel NUMERIC NULL,
	effort_kg NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Pedal_Effort;

CREATE TABLE IHT_Pedal_Effort (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Parameters TEXT NULL,				-- UKA4
	Efforts_Kg NUMERIC NULL,
	Travel_mm NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Gear_Effort;

CREATE TABLE IHT_Gear_Effort (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Parameters TEXT NULL,				-- UKA4
	Efforts_Kg NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Brake_Pedal_Effort;

cREATE TABLE IHT_Brake_Pedal_Effort (
	SYSPK serial NOT NULL,				-- PK  
	Client_Id INT NOT NULL,				-- UKA1 
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Srl_No TEXT NULL,
	Pedal_Effort_Kg NUMERIC NULL,		-- UKA4
	Pedal_Travel_RH_mm NUMERIC NULL,
	Pedal_Travel_LH_mm NUMERIC NULL,
	Pedal_Travel_Latched_mm NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Clutch_Pedal_Effort;

CREATE TABLE IHT_Clutch_Pedal_Effort (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Pedal_Effort_Kg NUMERIC NULL,		-- UKA4
	Srl_No TEXT NULL,
	Pedal_Travel_mm NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP  TABLE  if exists IHT_Hyd_Lift_Sensitivity;

CREATE TABLE IHT_Hyd_Lift_Sensitivity (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	TPL_load TEXT NULL,					-- UKA4
	Engine_RPM_type TEXT NULL,			-- UKA5
	Engine_RPM INT NULL,				-- UKA6
	lifting_time_sec NUMERIC NULL,
	Lowering_time_sec NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Speed_lead_lag_measurement;

CREATE TABLE IHT_Speed_lead_lag_measurement (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Gear TEXT NULL,						-- UKA4
	Engine_RPM INT NULL,
	Wheel_Drive_type TEXT NULL,
	No_of_Revolution_front NUMERIC NULL,
	Ratio NUMERIC NULL,
	Lead_Lag_PCT TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Gear_Max_Speed;

CREATE TABLE  IHT_Gear_Max_Speed (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_condition TEXT NULL,			-- UKA4
	Gear TEXT NULL,						-- UKA5
	LOW_1000_RPM NUMERIC NULL,
	RATED_2300_RPM NUMERIC NULL,
	HIGH_2500_RPM NUMERIC NULL,
	Specification NUMERIC NULL,
	Actual_Speed_pct NUMERIC NULL,
	Diff_in_Speed_KMPH NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Brake_Perf_test_condition;

CREATE TABLE IHT_Brake_Perf_test_condition (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	test_condition TEXT NULL,			-- UKA4
	Date_of_Test date NULL,
	Time_of_Test TEXT NULL,	
	Location_name TEXT NULL,
	Test_Mode TEXT NULL,
	Wind_velocity_kmph TEXT NULL,
	Ambient_Temp_C  NUMERIC NULL,
	HumIdity_RH_PCT NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Brake_Perf_test_results;

CREATE TABLE IHT_Brake_Perf_test_results (
	SYSPK serial NOT NULL,						-- PK
	Client_Id INT NOT NULL,						-- UKA1
	Function_Id INT NOT NULL,					-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,					-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_condition TEXT NULL,					-- UKA4
	test_mode TEXT NULL,						-- UKA5
	Srl_No INT NULL,
	Trigger_speed_km_per_h NUMERIC NULL,		-- UKA6
	Brake_Control_Input_Force_kg NUMERIC NULL,	-- UKA7
	Brake_perf_Test_condition_Id INT  NULL,
	Required_Corrected_Stopping_distance_m NUMERIC NULL,
	Actual_Stopping_Distance_m NUMERIC NULL,
	Deceleration_m_s2_V2_2s NUMERIC NULL,
	Observation TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Hot_Air_Mapping_Results;

CREATE TABLE IHT_Hot_Air_Mapping_Results (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Gear TEXT NULL,						-- UKA4
	Load_kg INT NULL,					-- UKA5
	Speed_kmph NUMERIC NULL,			
	Speed_rpm INT NULL,					-- UKA6
	Ambient_measured_temp_C INT NULL,
	Head_measured_temp_C INT NULL,
	Head_ROA_C INT NULL,
	Chest_measured_temp_C INT NULL,
	Chest_ROA_C INT NULL,
	LH_Leg_measured_temp_C INT NULL,
	LH_Leg_ROA_C INT NULL,
	RH_Leg_measured_temp_C INT NULL,
	RH_Leg_ROA_C INT NULL,
	RH_Hand_measured_temp_C INT NULL,
	RH_Hand_ROA_C INT NULL,
	LH_Hand_measured_temp_C INT NULL,
	LH_Hand_ROA_C INT NULL,
	Hood_Gas_spring_RH_sIde_measured_temp_C INT NULL,
	Hood_Gas_spring_RH_sIde_ROA_C INT NULL,
	Hood_foam_top_measured_temp_C INT NULL,
	Hood_foam_top_ROA_C INT NULL,
	Hood_foam_mIddle_measured_temp_C INT NULL,
	Hood_foam_mIddle_ROA_C INT NULL,
	Hood_foam_bottom_measured_temp_C INT NULL,
	Hood_foam_bottom_ROA_C INT NULL,
	outsIde_Hood_top_measured_temp_C INT NULL,
	outsIde_Hood_top_ROA_C INT NULL,
	outsIde_Hood_MIddle_measured_temp_C INT NULL,
	outsIde_Hood_MIddle_ROA_C INT NULL,
	outsIde_Hood_Bottom_measured_temp_C INT NULL,
	outsIde_Hood_Bottom_ROA_C INT NULL,
	Time_of_Test TIME NULL,
	Towards_main_security_gate_YN TEXT NULL,
	Time_Diff_h_min TIME NULL,
	Max_YN TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);

DROP TABLE if exists IHT_Noise_Measurement_Results;

CREATE TABLE IHT_Noise_Measurement_Results (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_Type TEXT  NULL,				-- UKA4
	Test_condition TEXT NULL,			-- UKA5
	Test_mode TEXT  NULL,				-- UKA6
	Gear TEXT  NULL,					-- UKA7
	Speed_rpm INT  NULL,
	speed_kmph NUMERIC NULL,
	Load_kg INT  NULL,
	noise_measurement_id int4 NULL,
	Noise_Level_1_dB_A NUMERIC NULL,
	Noise_Level_2_dB_A NUMERIC NULL,
	Noise_Level_3_dB_A NUMERIC NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);
 DROP TABLE if exists IHT_Noise_Measurement_test;
 
CREATE TABLE IHT_Noise_Measurement_test (
	SYSPK serial NOT NULL,				-- PK
	Client_Id INT NOT NULL,				-- UKA1
	Function_Id INT NOT NULL,			-- UKA2
	file_syspk INT  NULL,
	file_mnemonic TEXT  NULL,
	file_sheet_mnemonic TEXT  NULL,
	Test_Instance_Id INT  NULL,			-- UKA3
	Test_Instance_Tractor_Id INT NULL,
	Tractor_Model TEXT NULL,
	Tractor_Make TEXT NULL,
	Test_Type TEXT  NULL,				-- UKA4
	Test_condition TEXT NULL,			-- UKA5
	Test_mode TEXT  NULL,				-- UKA6
	remarks TEXT NULL,
	acceptance_criteria TEXT NULL,
	Created_By TEXT NULL DEFAULT current_user,
	Updated_by text NULL,
	Create_timestamp TIMESTAMP NULL DEFAULT now(),
	update_timestamp TIMESTAMP NULL
);