example FinanceColim1

////////////////////////////////////////////////////////////////////////
//
// Example courtesy of Jee Chung 
//
////////////////////////////////////////////////////////////////////////
// Uses the quotient technique to automatically compute the schema and
// instance colimits
////////////////////////////////////////////////////////////////////////

typeside Ty = literal {
	java_types	
		Integer = "java.lang.Integer"
		String = "java.lang.String"
		Double = "java.lang.Double"
		Boolean = "java.lang.String" 
		Date = "java.lang.String"
//		Date = "java.util.Date" alternative type for dates
	java_constants
		Integer = "return java.lang.Integer.parseInt(input[0]);"
		String = "return input[0]"
		Double = "return java.lang.Double.parseDouble(input[0])"
		Boolean = "return input[0]" 
		Date = "return input[0]"
//		Date = "return (new java.text.SimpleDateFormat(\"m/d/yyyy\").parse(input[0]));"
	java_functions
		keygen : Integer,Integer,Integer -> Integer = "return (2^input[0] * 3^input[1] * 5^input[2])"
}

		
////////////////////////////////////////////////////////////////////////
// Input schemas and instances separately
////////////////////////////////////////////////////////////////////////

// Compile time input
schema Client = literal : Ty {
	entities
		client
	attributes
		client_id : client -> Integer
		client_name : client -> String
		client_description : client -> String
} 

// Runtime input
instance ClientInstance = literal : Client {
     generators 
     	cc1 cc2 cc3 : client   	
     multi_equations //alternative, less verbose syntax
     	client_id -> {cc1 "1", cc2 "2", cc3 "3"}
     	client_name -> {cc1 Tom, cc2 Dick, cc3 Harry}
     	client_description -> {cc1 "Tom Client", cc2 "Dick Client", cc3 "Harry Client"}
} 

////////////////////////////////////////////////////////////////////////

// Compile time input
schema Portfolio = literal : Ty {
	entities
		strategy 
		portfolio
	foreign_keys			
		portfolio_strategy : portfolio -> strategy
		portfolio_parent_portfolio : portfolio -> portfolio //added
	path_equations
		portfolio.portfolio_parent_portfolio.portfolio_parent_portfolio = portfolio.portfolio_parent_portfolio //added required
	attributes			
		strategy_id : strategy -> Integer
		strategy_name : strategy -> String
		strategy_description : strategy -> String
		portfolio_id : portfolio -> Integer
		portfolio_name : portfolio -> String
		portfolio_description : portfolio -> String
		portfolio_client_client_id : portfolio -> Integer
		portfolio_strategy_strategy_id : portfolio -> Integer
		portfolio_parent_portfolio_portfolio_id : portfolio -> Integer //added 
	observation_equations
		forall p. p.portfolio_strategy.strategy_id = p.portfolio_strategy_strategy_id
		forall p. p.portfolio_parent_portfolio.portfolio_id = p.portfolio_parent_portfolio_portfolio_id //added
} 

// Runtime input
instance PortfolioInstance = literal : Portfolio {
     generators 
     	ps1 ps2 ps3 : strategy //not having ps2 here is really weird because it means this instance has nulls in it 
     	pp1 pp2 pp3 : portfolio
     equations
		pp1.portfolio_parent_portfolio_portfolio_id = "1" pp1.portfolio_parent_portfolio = pp1 //pp1 is parent of itself
		pp2.portfolio_parent_portfolio_portfolio_id = "2" pp2.portfolio_parent_portfolio = pp2 //pp2 is parent of itself
		pp3.portfolio_parent_portfolio_portfolio_id = "2" pp3.portfolio_parent_portfolio = pp2 //pp3's parent is pp2
     
		ps1.strategy_id = "1" ps1.strategy_name = Strat1 ps1.strategy_description = Strategy1 
		ps2.strategy_id = "2" ps2.strategy_name = Strat2 ps2.strategy_description = Strategy2 
		ps3.strategy_id = "3" ps3.strategy_name = Strat3 ps3.strategy_description = Strategy3 
		pp1.portfolio_id = "1" pp1.portfolio_name = Port1 pp1.portfolio_description = Portfolio1 pp1.portfolio_client_client_id = "1" pp1.portfolio_strategy_strategy_id = "2" pp1.portfolio_strategy = ps2
		pp2.portfolio_id = "2" pp2.portfolio_name = Port2 pp2.portfolio_description = Portfolio2 pp2.portfolio_client_client_id = "2" pp2.portfolio_strategy_strategy_id = "2" pp2.portfolio_strategy = ps2
		pp3.portfolio_id = "3" pp3.portfolio_name = Port3 pp3.portfolio_description = Portfolio3 pp3.portfolio_client_client_id = "2" pp3.portfolio_strategy_strategy_id = "1" pp3.portfolio_strategy = ps1
} 

////////////////////////////////////////////////////////////////////////

// Compile time input		
schema Ref = literal : Ty {
	entities
		country 
		currency 
		asset 
		strategy
	foreign_keys
		currency_country : currency -> country
		asset_strategy : asset -> strategy
	attributes	
		country_id : country -> Integer
		country_code : country -> String
		country_name : country -> String
		asset_id : asset -> Integer
		asset_name : asset -> String
		asset_description : asset -> String
		asset_strategy_strategy_id : asset -> Integer
		strategy_id : strategy -> Integer
		strategy_name : strategy -> String
		strategy_description : strategy -> String
		currency_id : currency -> Integer
		currency_code : currency -> String
		currency_name : currency -> String
		currency_country_country_id : currency -> Integer
	observation_equations	
		forall c. c.currency_country.country_id = c.currency_country_country_id
		forall a. a.asset_strategy.strategy_id = a.asset_strategy_strategy_id
} 	

// Runtime input
instance RefInstance = literal : Ref {
     generators 
     	rcty1 rcty2 rcty3 rcty4 rcty5 rcty6 : country 
		rcur1 rcur2 rcur3 : currency 
		ra1 ra2 ra3 ra4 ra5 ra6 ra7 ra8 ra9 ra10 : asset 
		rs1 rs2 rs3 rs4 rs5 : strategy
     equations	
 		rcty1.country_id = "1" rcty1.country_code = AU rcty1.country_name = Australia 
 		rcty2.country_id = "2" rcty2.country_code = CH rcty2.country_name = Switzerland 
 		rcty3.country_id = "3" rcty3.country_code = CN rcty3.country_name = China 
 		rcty4.country_id = "4" rcty4.country_code = EU rcty4.country_name = "European Union" 
 		rcty5.country_id = "5" rcty5.country_code = JP rcty5.country_name = Japan 
 		rcty6.country_id = "6" rcty6.country_code = US rcty6.country_name = "United States of America" 
 		rcur1.currency_id = "1" rcur1.currency_code = USD rcur1.currency_name = "US Dollar" rcur1.currency_country_country_id  = "6" rcur1.currency_country = rcty6 
		rcur2.currency_id = "2" rcur2.currency_code = EUR rcur2.currency_name = "Euro" rcur2.currency_country_country_id  = "4" rcur2.currency_country = rcty4 
		rcur3.currency_id = "3" rcur3.currency_code = JPY rcur3.currency_name = "Japanese Yen" rcur3.currency_country_country_id  = "5" rcur3.currency_country = rcty5 	 		 		
		ra1.asset_id = "1" ra1.asset_name = A1 ra1.asset_description = Asset1 ra1.asset_strategy_strategy_id = "1" ra1.asset_strategy = rs1 
		ra2.asset_id = "2" ra2.asset_name = A2 ra2.asset_description = Asset2 ra2.asset_strategy_strategy_id = "3" ra2.asset_strategy = rs3
		ra3.asset_id = "3" ra3.asset_name = A3 ra3.asset_description = Asset3 ra3.asset_strategy_strategy_id = "2" ra3.asset_strategy = rs2		 
		ra4.asset_id = "4" ra4.asset_name = A4 ra4.asset_description = Asset4 ra4.asset_strategy_strategy_id = "4" ra4.asset_strategy = rs4
		ra5.asset_id = "5" ra5.asset_name = A5 ra5.asset_description = Asset5 ra5.asset_strategy_strategy_id = "5" ra5.asset_strategy = rs5
		ra6.asset_id = "6" ra6.asset_name = A6 ra6.asset_description = Asset6 ra6.asset_strategy_strategy_id = "4" ra6.asset_strategy = rs4
		ra7.asset_id = "7" ra7.asset_name = A7 ra7.asset_description = Asset7 ra7.asset_strategy_strategy_id = "4" ra7.asset_strategy = rs4
		ra8.asset_id = "8" ra8.asset_name = A8 ra8.asset_description = Asset8 ra8.asset_strategy_strategy_id = "5" ra8.asset_strategy = rs5
		ra9.asset_id = "9" ra9.asset_name = A9 ra9.asset_description = Asset9 ra9.asset_strategy_strategy_id = "3" ra9.asset_strategy = rs3
		ra10.asset_id = "10" ra10.asset_name = A10 ra10.asset_description = Asset10 ra10.asset_strategy_strategy_id = "1" ra10.asset_strategy = rs1
		rs1.strategy_id = "1" rs1.strategy_name = Strat1 rs1.strategy_description = Strategy1 
		rs2.strategy_id = "2" rs2.strategy_name = Strat2 rs2.strategy_description = Strategy2 
		rs3.strategy_id = "3" rs3.strategy_name = Strat3 rs3.strategy_description = Strategy3 
		rs4.strategy_id = "4" rs4.strategy_name = Strat4 rs4.strategy_description = Strategy4 
		rs5.strategy_id = "5" rs5.strategy_name = Strat5 rs5.strategy_description = Strategy5
} 

////////////////////////////////////////////////////////////////////////

// Compile time input		
schema Trans = literal : Ty {
	entities
		asset 
		currency 
		transaction
	foreign_keys
		transaction_asset : transaction -> asset
		transaction_currency : transaction -> currency
	attributes	
		asset_id : asset -> Integer
		asset_name : asset -> String
		asset_description : asset -> String
		currency_id : currency -> Integer
		currency_code : currency -> String
		currency_name : currency -> String
		transaction_id : transaction -> Integer
		transaction_date : transaction -> Date	// added as a new column
		transaction_asset_asset_id : transaction -> Integer
		transaction_portfolio_portfolio_id : transaction -> Integer
		transaction_buy_sell_ind : transaction -> Boolean
		transaction_quantity : transaction -> Integer
		transaction_price : transaction -> Double
		transaction_currency_currency_id : transaction -> Integer
	observation_equations	
		forall t. t.transaction_asset.asset_id = t.transaction_asset_asset_id
		forall t. t.transaction_currency.currency_id = t.transaction_currency_currency_id
} 

// Runtime input
instance TransInstance = literal : Trans {
     generators 
		ta1 ta3 ta5 ta7 ta9 : asset 
		tc1 tc2 tc3 : currency 
		tt1 tt2 tt3 tt4 tt5 tt6 : transaction
     equations
		ta1.asset_id = "1" ta1.asset_name = A1 ta1.asset_description = Asset1 
		ta3.asset_id = "3" ta3.asset_name = A3 ta3.asset_description = Asset3 
		ta5.asset_id = "5" ta5.asset_name = A5 ta5.asset_description = Asset5 
		ta7.asset_id = "7" ta7.asset_name = A7 ta7.asset_description = Asset7 
		ta9.asset_id = "9" ta9.asset_name = A9 ta9.asset_description = Asset9 
		tc1.currency_id = "1" tc1.currency_code = USD tc1.currency_name = "US Dollar" 
		tc2.currency_id = "2" tc2.currency_code = EUR tc2.currency_name = Euro 
		tc3.currency_id = "3" tc3.currency_code = JPY tc3.currency_name = "Japanese Yen" 
		tt1.transaction_id = "1" tt1.transaction_asset_asset_id = "1" tt1.transaction_asset = ta1 tt1.transaction_portfolio_portfolio_id = "1" tt1.transaction_buy_sell_ind = buy tt1.transaction_quantity = "200" tt1.transaction_price = "5.51" tt1.transaction_currency_currency_id  = "2" tt1.transaction_currency = tc2 tt1.transaction_date = "1/1/2011"
		tt2.transaction_id = "2" tt2.transaction_asset_asset_id = "1" tt2.transaction_asset = ta1 tt2.transaction_portfolio_portfolio_id = "1" tt2.transaction_buy_sell_ind = sell tt2.transaction_quantity = "100" tt2.transaction_price = "5.5" tt2.transaction_currency_currency_id  = "2" tt2.transaction_currency = tc2 tt2.transaction_date = "6/1/2011"
		tt3.transaction_id = "3" tt3.transaction_asset_asset_id = "3" tt3.transaction_asset = ta3 tt3.transaction_portfolio_portfolio_id = "2" tt3.transaction_buy_sell_ind = buy tt3.transaction_quantity = "150" tt3.transaction_price = "2.5" tt3.transaction_currency_currency_id  = "1" tt3.transaction_currency = tc1 tt3.transaction_date = "9/1/2013"
		tt4.transaction_id = "4" tt4.transaction_asset_asset_id = "3" tt4.transaction_asset = ta3 tt4.transaction_portfolio_portfolio_id = "2" tt4.transaction_buy_sell_ind = sell tt4.transaction_quantity = "150" tt4.transaction_price = "3.5" tt4.transaction_currency_currency_id  = "1" tt4.transaction_currency = tc1 tt4.transaction_date = "3/1/2014"
		tt5.transaction_id = "5" tt5.transaction_asset_asset_id = "5" tt5.transaction_asset = ta5 tt5.transaction_portfolio_portfolio_id = "3" tt5.transaction_buy_sell_ind = buy tt5.transaction_quantity = "200" tt5.transaction_price = "1.6" tt5.transaction_currency_currency_id  = "3" tt5.transaction_currency = tc3 tt5.transaction_date = "2/1/2013"
		tt6.transaction_id = "6" tt6.transaction_asset_asset_id = "5" tt6.transaction_asset = ta5 tt6.transaction_portfolio_portfolio_id = "3" tt6.transaction_buy_sell_ind = sell tt6.transaction_quantity = "100" tt6.transaction_price = "1.5" tt6.transaction_currency_currency_id  = "3" tt6.transaction_currency = tc3 tt6.transaction_date = "7/1/2013"
} 

////////////////////////////////////////////////////////////////////////

// Compile time input
schema HoldPos = literal : Ty {
	entities
		client 
		holding 
		position
	foreign_keys	
		holding_client : holding -> client
		position_client : position -> client
	attributes	
		client_no : client -> Integer	// new name
		client_nm : client -> String	// new name
		client_desc : client -> String	// new name
		holding_id : holding -> Integer
		holding_client_client_no : holding -> Integer	// new name
		holding_portfolio_portfolio_id : holding -> Integer
		holding_asset_asset_id : holding -> Integer
		holding_quantity : holding -> Integer
		holding_purchase_date : holding -> Date
		holding_purchase_price : holding -> Double
		holding_currency_currency_code : holding -> String	// switched from _id to _code
		holding_begin_date : holding -> Date	// new attribute
		holding_end_date : holding -> Date		// new attribute
		position_id : position -> Integer
		position_client_client_no : position -> Integer	// new name
		position_asset_asset_id : position -> Integer
		position_quantity : position -> Integer
		position_current_value : position -> Integer
		position_current_value_currency_currency_code : position -> String	// switched from _id to _code
		position_cost_basis : position -> Integer
		position_cost_basis_currency_currency_code : position -> String	// switched from _id to _code
	observation_equations	
		forall h. h.holding_client.client_no = h.holding_client_client_no
		forall p. p.position_client.client_no = p.position_client_client_no
} 

// Runtime input
instance HoldPosInstance = literal : HoldPos {
     generators 
  		hpc1 hpc2 : client 
		hph1 hph2 hph3 hph4 hph5 : holding 
		hpp1 hpp2 : position
     equations
		// below lines were also updated to reflect the new column names in HoldPos.client
		hpc1.client_no  = "1" hpc1.client_nm = Tom hpc1.client_desc = "Tom Client" 
		hpc2.client_no  = "2" hpc2.client_nm = Dick hpc2.client_desc = "Dick Client" 

		// inserted two holding instances with IDs 2 & 5 ID values for all instances except 1 were adjusted
		hph1.holding_id = "1" hph1.holding_client_client_no = "1" hph1.holding_client = hpc1 hph1.holding_portfolio_portfolio_id = "1" hph1.holding_asset_asset_id = "1" hph1.holding_quantity = "200" hph1.holding_purchase_date = "1/1/2011" hph1.holding_purchase_price = "5.51" hph1.holding_currency_currency_code = "EUR" hph1.holding_begin_date = "1/1/2011" hph1.holding_end_date = "6/1/2011"
		hph2.holding_id = "2" hph2.holding_client_client_no = "1" hph2.holding_client = hpc1 hph2.holding_portfolio_portfolio_id = "1" hph2.holding_asset_asset_id = "1" hph2.holding_quantity = "100" hph2.holding_purchase_date = "1/1/2011" hph2.holding_purchase_price = "5.51" hph2.holding_currency_currency_code = "EUR" hph2.holding_begin_date = "6/1/2011"
		hph3.holding_id = "3" hph3.holding_client_client_no = "2" hph3.holding_client = hpc2 hph3.holding_portfolio_portfolio_id = "3" hph3.holding_asset_asset_id = "3" hph3.holding_quantity = "150" hph3.holding_purchase_date = "9/1/2013" hph3.holding_purchase_price = "2.5"  hph3.holding_currency_currency_code = "USD" hph3.holding_begin_date = "9/1/2013" hph3.holding_end_date = "3/1/2014"
		hph4.holding_id = "4" hph4.holding_client_client_no = "2" hph4.holding_client = hpc2 hph4.holding_portfolio_portfolio_id = "3" hph4.holding_asset_asset_id = "5" hph4.holding_quantity = "200" hph4.holding_purchase_date = "2/1/2013" hph4.holding_purchase_price = "1.6"  hph4.holding_currency_currency_code = "JPY" hph4.holding_begin_date = "2/1/2013" hph4.holding_end_date = "7/1/2013"
		hph5.holding_id = "5" hph5.holding_client_client_no = "2" hph5.holding_client = hpc2 hph5.holding_portfolio_portfolio_id = "3" hph5.holding_asset_asset_id = "5" hph5.holding_quantity = "100" hph5.holding_purchase_date = "2/1/2013" hph5.holding_purchase_price = "1.6"  hph5.holding_currency_currency_code = "JPY" hph5.holding_begin_date = "7/1/2013"

		hpp1.position_id = "1" hpp1.position_client_client_no = "1" hpp1.position_client = hpc1 hpp1.position_asset_asset_id = "1" hpp1.position_quantity = "100" hpp1.position_current_value = "550" hpp1.position_current_value_currency_currency_code = "EUR" hpp1.position_cost_basis = "551" hpp1.position_cost_basis_currency_currency_code = "EUR"		
		hpp2.position_id = "2" hpp2.position_client_client_no = "2" hpp2.position_client = hpc2 hpp2.position_asset_asset_id = "5" hpp2.position_quantity = "100" hpp2.position_current_value = "170" hpp2.position_current_value_currency_currency_code = "JPY" hpp2.position_cost_basis = "160" hpp2.position_cost_basis_currency_currency_code = "JPY"
} 


////////////////////////////////////////////////////////////////////////
// Compute the canonical colimit schema using the quotient method
////////////////////////////////////////////////////////////////////////
schema_colimit Colimit = quotient Client + Ref + Trans + Portfolio + HoldPos : Ty {
	 entity_equations
		Client.client = HoldPos.client
		Ref.asset     = Trans.asset
		Ref.currency  = Trans.currency
		Ref.strategy  = Portfolio.strategy
	observation_equations
		forall x. x.Client_client_client_id          = x.HoldPos_client_client_no
		forall x. x.Client_client_client_name        = x.HoldPos_client_client_nm
		forall x. x.Client_client_client_description = x.HoldPos_client_client_desc

		forall x. x.Ref_strategy_strategy_id          = x.Portfolio_strategy_strategy_id
		forall x. x.Ref_strategy_strategy_name        = x.Portfolio_strategy_strategy_name
		forall x. x.Ref_strategy_strategy_description = x.Portfolio_strategy_strategy_description

		forall x. x.Ref_asset_asset_id          = x.Trans_asset_asset_id
		forall x. x.Ref_asset_asset_name        = x.Trans_asset_asset_name
		forall x. x.Ref_asset_asset_description = x.Trans_asset_asset_description

		forall x. x.Ref_currency_currency_id   = x.Trans_currency_currency_id
		forall x. x.Ref_currency_currency_code = x.Trans_currency_currency_code
		forall x. x.Ref_currency_currency_name = x.Trans_currency_currency_name
	options
		simplify_names=false	 
}


////////////////////////////////////////////////////////////////////////
// The instance coproduct
////////////////////////////////////////////////////////////////////////

instance ClientFwd = sigma (getMapping Colimit Client) ClientInstance
instance PortfolioFwd = sigma (getMapping Colimit Portfolio) PortfolioInstance
instance RefFwd = sigma (getMapping Colimit Ref) RefInstance 
instance TransFwd = sigma (getMapping Colimit Trans) TransInstance
instance HoldPosFwd = sigma (getMapping Colimit HoldPos) HoldPosInstance

instance CoProd = literal : getSchema Colimit {
	imports 
		ClientFwd PortfolioFwd  RefFwd  TransFwd  HoldPosFwd 
}

////////////////////////////////////////////////////////////////////////
// The quotient instance
////////////////////////////////////////////////////////////////////////
instance E = literal : getSchema Colimit {
	generators
		ec1 ec2 : Client_client__HoldPos_client
		ea1 ea3 ea5 ea7 ea9 : Ref_asset__Trans_asset
		ecur1 ecur2 ecur3 :  Ref_currency__Trans_currency
		es1 es2 es3 : Portfolio_strategy__Ref_strategy
}


////////////////////////////////////////////////////////////////////////
// The transforms
////////////////////////////////////////////////////////////////////////
transform a1 = literal : E -> CoProd {
	generators
		ec1 -> cc1
		ec2 -> cc2
		ea1 -> ra1
		ea3 -> ra3 
		ea5 -> ra5 
		ea7 -> ra7
		ea9 -> ra9
		ecur1 -> rcur1
		ecur2 -> rcur2
		ecur3 -> rcur3
		es1 -> rs1
		es2 -> rs2
		es3 -> rs3
}

transform a2 = literal : E -> CoProd {
	generators
		ec1 -> hpc1
		ec2 -> hpc2
		ea1 -> ta1
		ea3 -> ta3 
		ea5 -> ta5 
		ea7 -> ta7
		ea9 -> ta9
		ecur1 -> tc1
		ecur2 -> tc2
		ecur3 -> tc3
		es1 -> ps1
		es2 -> ps2
		es3 -> ps3
}


////////////////////////////////////////////////////////////////////////
// The final step
////////////////////////////////////////////////////////////////////////
instance ColimitInstance = coequalize a1 a2


////////////////////////////////////////////////////////////////////////
//Desired Target Schema translated from asset-mgmt-er.pdf
////////////////////////////////////////////////////////////////////////

//compile time input
schema Target = literal : Ty {
	entities
		currency //Trans Ref
		strategy //Portfolio Ref
		asset //Trans Ref
		transaction //Trans
		client //HoldPos
		position //HoldPos
		country //Ref
		portfolioholding //NEW
		portfolio //Portfolio 
		holding //HoldPos
	
	foreign_keys
		portfolio_strategy : portfolio -> strategy //Portfolio
		portfolio_parent_portfolio : portfolio -> portfolio //Added for cyclic FK on Portfolio.portfolio.  ryan also added the cyclic fk to 
		
		position_client : position -> client //HoldPos
		position_asset : position -> asset //NEW
		position_current_value_currency : position -> currency //NEW
		position_cost_basis_currency : position -> currency //NEW
		
		asset_strategy : asset -> strategy //Ref
		
		currency_country : currency -> country //Ref 
		
		transaction_currency : transaction -> currency //Trans 
		transaction_asset : transaction -> asset //Trans 
		transaction_portfolio : transaction -> portfolio //NEW

		holding_currency : holding -> currency //NEW
		// added below we might have missed in defining the "target" schema we had used in "er_pushout.opl"
		// ryan concurs.  todo: meaningless ID discussion 
		holding_asset : holding -> asset

		// below is supposed to be the analog of the "junction table" between client portfolio & holding
		// but in looking at the holding table above seems redundant. Why is that?
		portfolioholding_holding : portfolioholding -> holding //NEW
		portfolioholding_client : portfolioholding -> client //NEW 
		portfolioholding_portfolio : portfolioholding -> portfolio //NEW
	
	path_equations
		//todo: revisit scenario using parent . client = client rather than parent . parent = parent
		portfolio.portfolio_parent_portfolio.portfolio_parent_portfolio = portfolio.portfolio_parent_portfolio

	attributes
		currency_code : currency -> String //Trans Ref
		currency_name : currency -> String //Trans Ref
		currency_id : currency -> Integer //Ref
		currency_country_country_id : currency -> Integer //Ref

		country_code : country -> String //Ref
		country_name : country -> String //Ref
		country_id : country -> Integer //Ref		

		asset_id : asset -> Integer //Trans Ref
		asset_description : asset -> String //Trans Ref
		asset_name : asset -> String //Trans Ref
		asset_strategy_strategy_id : asset -> Integer //Ref
				
		strategy_name : strategy -> String //Ref Portfolio
		strategy_description : strategy -> String //Ref Portfolio
		strategy_id : strategy -> Integer //Ref Portfolio		

		portfolio_name : portfolio -> String //Portfolio
		portfolio_description : portfolio -> String //Portfolio
		portfolio_id : portfolio -> Integer //Portfolio
		portfolio_strategy_strategy_id : portfolio -> Integer //Portfolio
		portfolio_parent_portfolio_portfolio_id : portfolio -> Integer	//Portfolio ADDED
		
		position_quantity : position -> Integer //HoldPos
		position_current_value : position -> Integer //HoldPos
		position_cost_basis : position -> Integer //HoldPos
		position_id : position -> Integer //HoldPos
		position_client_client_id : position -> Integer //HoldPos
		position_asset_asset_id : position -> Integer //HoldPos
		position_current_value_currency_currency_id : position -> Integer // HoldPos 
		position_cost_basis_currency_currency_id : position -> Integer // HoldPos		

		holding_id : holding -> Integer //HoldPos				
		holding_asset_asset_id : holding -> Integer //HoldPos
		holding_currency_currency_id : holding -> Integer //HoldPos
		holding_purchase_price : holding -> Double //HoldPos
		holding_quantity : holding -> Integer //HoldPos //HoldPos
		holding_purchase_date : holding -> Date //HoldPos		
		holding_begin_date : holding -> Date //HoldPos new attribute
		holding_end_date : holding -> Date //HoldPos new attribute

		client_description : client -> String //HoldPos
		client_name : client -> String //HoldPos
		client_id : client -> Integer //HoldPos		

		transaction_id : transaction -> Integer //Trans
		transaction_asset_asset_id : transaction -> Integer //Trans
		transaction_buy_sell_ind : transaction -> Boolean //Trans
		transaction_quantity : transaction -> Integer //Trans
		transaction_price : transaction -> Double //Trans
		transaction_currency_currency_id : transaction -> Integer //Trans			
		transaction_portfolio_portfolio_id : transaction -> Integer //Trans
		transaction_date : transaction -> Date	//added as a new column

		portfolioholding_id : portfolioholding -> Integer //NEW todo: talk to Jee about this
		portfolioholding_holding_holding_id : portfolioholding -> Integer //NEW
		portfolioholding_client_client_id : portfolioholding -> Integer //NEW
		portfolioholding_portfolio_portfolio_id : portfolioholding -> Integer //NEW
	
	observation_equations
		forall p. p.portfolio_parent_portfolio.portfolio_id = p.portfolio_parent_portfolio_portfolio_id //added
		forall p. p.portfolio_strategy.strategy_id = p.portfolio_strategy_strategy_id
		forall a. a.asset_strategy.strategy_id = a.asset_strategy_strategy_id	
		forall p. p.position_client.client_id = p.position_client_client_id
		forall c. c.currency_country.country_id = c.currency_country_country_id
		forall t. t.transaction_currency.currency_id = t.transaction_currency_currency_id
		forall t. t.transaction_asset.asset_id = t.transaction_asset_asset_id
		forall p. p.portfolioholding_holding.holding_id = p.portfolioholding_holding_holding_id
		forall p. p.portfolioholding_client.client_id = p.portfolioholding_client_client_id	
		forall p. p.portfolioholding_portfolio.portfolio_id = p.portfolioholding_portfolio_portfolio_id					
		forall p. p.position_asset.asset_id = p.position_asset_asset_id
		forall h. h.holding_currency.currency_id = h.holding_currency_currency_id
		forall t. t.transaction_portfolio.portfolio_id = t.transaction_portfolio_portfolio_id
		forall p. p.position_current_value_currency.currency_id = p.position_current_value_currency_currency_id
		forall p. p.position_cost_basis_currency.currency_id = p.position_cost_basis_currency_currency_id	
}


////////////////////////////////////////////////////////////////////////
//An uber-flower to migrate from Colim to Target
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

query ETL = literal : getSchema Colimit -> Target {
 entity
 
	//identity
	currency -> {from c:Ref_currency__Trans_currency
		attributes currency_code -> c.Ref_currency_currency_code
			currency_name -> c.Ref_currency_currency_name
			currency_id -> c.Ref_currency_currency_id
			currency_country_country_id -> c.Ref_currency_currency_country_country_id
foreign_keys
 	currency_country -> {c -> c.Ref_currency_currency_country} 		
	} 

	//identity
entity	strategy -> {from s:Portfolio_strategy__Ref_strategy
		attributes strategy_name -> s.Ref_strategy_strategy_name
			strategy_description -> s.Ref_strategy_strategy_description
			strategy_id -> s.Ref_strategy_strategy_id

	}

	//identity
entity	asset -> {from a:Ref_asset__Trans_asset
		attributes asset_id -> a.Ref_asset_asset_id
			asset_description -> a.Ref_asset_asset_description
			asset_name -> a.Ref_asset_asset_name
			asset_strategy_strategy_id -> a.Ref_asset_asset_strategy_strategy_id
foreign_keys
 	asset_strategy -> {s -> a.Ref_asset_asset_strategy} 		
		
	} 

	//identity
entity	client -> {from c:Client_client__HoldPos_client 
		attributes client_description -> c.Client_client_client_description 
			client_name -> c.Client_client_client_name
			client_id -> c.Client_client_client_id

	} 

	//identity
entity	country -> {from c:Ref_country
		attributes country_code -> c.Ref_country_country_code
			country_name -> c.Ref_country_country_name
			country_id -> c.Ref_country_country_id

	} 

	//not identity
entity	transaction -> {from t:Trans_transaction p:Portfolio_portfolio c:Client_client__HoldPos_client c1:Client_client__HoldPos_client
		where t.Trans_transaction_transaction_portfolio_portfolio_id = p.Portfolio_portfolio_portfolio_id
		attributes transaction_id -> t.Trans_transaction_transaction_id 
			transaction_asset_asset_id -> t.Trans_transaction_transaction_asset_asset_id 
			transaction_buy_sell_ind -> t.Trans_transaction_transaction_buy_sell_ind 
			transaction_quantity -> t.Trans_transaction_transaction_quantity
			transaction_price -> t.Trans_transaction_transaction_price 
			transaction_date -> t.Trans_transaction_transaction_date
			transaction_currency_currency_id -> t.Trans_transaction_transaction_currency_currency_id 			
			transaction_portfolio_portfolio_id -> t.Trans_transaction_transaction_portfolio_portfolio_id
foreign_keys
 transaction_currency -> {c -> t.Trans_transaction_transaction_currency} 
	transaction_asset -> {a -> t.Trans_transaction_transaction_asset} 
	transaction_portfolio -> {p -> p} 	//NEW	
		}

	//not identity
entity	position -> {from p:HoldPos_position a:Ref_asset__Trans_asset cv:Ref_currency__Trans_currency cb:Ref_currency__Trans_currency
		where p.HoldPos_position_position_asset_asset_id = a.Ref_asset_asset_id
			p.HoldPos_position_position_current_value_currency_currency_code = cv.Ref_currency_currency_code
			p.HoldPos_position_position_cost_basis_currency_currency_code = cb.Ref_currency_currency_code
		attributes position_quantity -> p.HoldPos_position_position_quantity
			position_current_value -> p.HoldPos_position_position_current_value
			position_cost_basis -> p.HoldPos_position_position_cost_basis
			position_id -> p.HoldPos_position_position_id 
			position_client_client_id -> p.HoldPos_position_position_client_client_no
			position_asset_asset_id -> p.HoldPos_position_position_asset_asset_id
			position_current_value_currency_currency_id -> cv.Ref_currency_currency_id
			position_cost_basis_currency_currency_id -> cb.Ref_currency_currency_id
 foreign_keys
 	position_client -> {c -> p.HoldPos_position_position_client} 
	position_asset -> {a -> a}  //NEW
	position_current_value_currency -> {c -> cv}  //NEW
	position_cost_basis_currency -> {c -> cb}  //NEW
	} 

	//not identity
	entity portfolio -> {from p:Portfolio_portfolio
		attributes portfolio_parent_portfolio_portfolio_id -> p.Portfolio_portfolio_portfolio_parent_portfolio_portfolio_id //added
			portfolio_name -> p.Portfolio_portfolio_portfolio_name
			portfolio_description -> p.Portfolio_portfolio_portfolio_description
			portfolio_id -> p.Portfolio_portfolio_portfolio_id
			portfolio_strategy_strategy_id -> p.Portfolio_portfolio_portfolio_strategy_strategy_id
 foreign_keys
 	portfolio_parent_portfolio -> {p -> p.Portfolio_portfolio_portfolio_parent_portfolio}  //added
	portfolio_strategy -> {s -> p.Portfolio_portfolio_portfolio_strategy} 
	} 

	//not identity
	entity holding -> {from h:HoldPos_holding c:Ref_currency__Trans_currency a:Ref_asset__Trans_asset
		where a.Ref_asset_asset_id = h.HoldPos_holding_holding_asset_asset_id
			h.HoldPos_holding_holding_currency_currency_code = c.Ref_currency_currency_code
		attributes holding_id -> h.HoldPos_holding_holding_id			
			holding_asset_asset_id -> h.HoldPos_holding_holding_asset_asset_id
			holding_currency_currency_id -> c.Ref_currency_currency_id 			
			holding_purchase_price -> h.HoldPos_holding_holding_purchase_price 
			holding_quantity -> h.HoldPos_holding_holding_quantity 
			holding_purchase_date -> h.HoldPos_holding_holding_purchase_date 
			holding_begin_date -> h.HoldPos_holding_holding_begin_date 
			holding_end_date -> h.HoldPos_holding_holding_end_date
			foreign_keys
 	holding_asset -> {a -> a} 
	holding_currency -> {c -> c}  //NEW
	
	} 
   
	//not identity
	// Q: In this particular query, I had to rename h.holding_client
	//    to h.HoldPos_holding_holding_client. I did not have to do that for
	//    the other FKs. Why? There is a line in the foreign_keys
	//    section that names portfolioholding_client to that.
entity	portfolioholding -> {from h:HoldPos_holding p:Portfolio_portfolio cur: Ref_currency__Trans_currency c1:Client_client__HoldPos_client a:Ref_asset__Trans_asset
		where a.Ref_asset_asset_id = h.HoldPos_holding_holding_asset_asset_id
			p.Portfolio_portfolio_portfolio_parent_portfolio.Portfolio_portfolio_portfolio_client_client_id = c1.Client_client_client_id
			c1.Client_client_client_id = h.HoldPos_holding_holding_client.Client_client_client_id
			h.HoldPos_holding_holding_currency_currency_code = cur.Ref_currency_currency_code
			p.Portfolio_portfolio_portfolio_client_client_id = h.HoldPos_holding_holding_client.Client_client_client_id
			h.HoldPos_holding_holding_portfolio_portfolio_id = p.Portfolio_portfolio_portfolio_id
		attributes portfolioholding_id -> keygen(h.HoldPos_holding_holding_id, h.HoldPos_holding_holding_client.Client_client_client_id, p.Portfolio_portfolio_portfolio_id) //added by ryan
			portfolioholding_holding_holding_id -> h.HoldPos_holding_holding_id
			portfolioholding_client_client_id -> c1.Client_client_client_id
			portfolioholding_portfolio_portfolio_id -> p.Portfolio_portfolio_portfolio_id
foreign_keys
 
	portfolioholding_holding -> {h -> h c -> cur a -> a}
	portfolioholding_client -> {c -> h.HoldPos_holding_holding_client}  
	portfolioholding_portfolio -> {p -> p} 	
	}

} 

instance Output = eval ETL ColimitInstance


////////////////////////////////////////////////////////////////////////
// Target schema A - cyclic FK version (on the Portfolio entity)
////////////////////////////////////////////////////////////////////////

schema CycTarget = literal : Ty {
	entities
		client
		country
		currency
		strategy
		asset
		portfolio
		transaction
		clientposition
		clientportfolioholding

	foreign_keys
		currency_country : currency -> country

		asset_strategy : asset -> strategy

		portfolio_strategy : portfolio -> strategy
		portfolio_parent_portfolio : portfolio -> portfolio // for cyclic FK on portfolio

		transaction_currency : transaction -> currency
		transaction_asset : transaction -> asset
		transaction_portfolio : transaction -> portfolio

		clientposition_client : clientposition -> client
		clientposition_asset : clientposition -> asset

		clientportfolioholding_asset : clientportfolioholding -> asset
		clientportfolioholding_client : clientportfolioholding -> client
		clientportfolioholding_portfolio : clientportfolioholding -> portfolio

	path_equations
		//added by ryan
		portfolio.portfolio_parent_portfolio.portfolio_parent_portfolio = portfolio.portfolio_parent_portfolio 

	attributes
		client_id : client -> Integer
		client_name : client -> String
		client_description : client -> String

		country_id : country -> Integer
		country_code : country -> String
		country_name : country -> String

		currency_id : currency -> Integer
		currency_code : currency -> String
		currency_name : currency -> String
		currency_country_country_id : currency -> Integer

		asset_id : asset -> Integer
		asset_name : asset -> String
		asset_description : asset -> String
		asset_strategy_strategy_id : asset -> Integer

		strategy_id : strategy -> Integer
		strategy_name : strategy -> String
		strategy_description : strategy -> String

		portfolio_id : portfolio -> Integer
		portfolio_name : portfolio -> String
		portfolio_description : portfolio -> String
		portfolio_strategy_strategy_id : portfolio -> Integer
		portfolio_parent_portfolio_portfolio_id : portfolio -> Integer // for cyclic FK on portfolio

		transaction_id : transaction -> Integer
		transaction_date : transaction -> Date
		transaction_portfolio_portfolio_id : transaction -> Integer
		transaction_portfolio_portfolio_name : transaction -> String // intentionally added for query convenience
		transaction_asset_asset_id : transaction -> Integer
		transaction_asset_asset_name : transaction -> String // intentionally added for query convenience
		transaction_buy_sell_ind : transaction -> Boolean
		transaction_quantity : transaction -> Integer
		transaction_price : transaction -> Double
		transaction_currency_currency_id : transaction -> Integer

		clientposition_id : clientposition -> Integer
		clientposition_begin_date : clientposition -> Date
		clientposition_end_date : clientposition -> Date
		clientposition_client_client_id : clientposition -> Integer
		clientposition_client_client_name : clientposition -> String // intentionally added for query convenience
		clientposition_asset_asset_id : clientposition -> Integer
		clientposition_asset_asset_name : clientposition -> String // intentionally added for query convenience
		clientposition_quantity : clientposition -> Integer
		clientposition_current_value : clientposition -> Integer
		clientposition_current_value_currency_currency_code : clientposition -> String // intentionally code instead of id for query convenience

		clientportfolioholding_id : clientportfolioholding -> Integer
		clientportfolioholding_begin_date : clientportfolioholding -> Date
		clientportfolioholding_end_date : clientportfolioholding -> Date
		clientportfolioholding_portfolio_portfolio_id : clientportfolioholding -> Integer
		clientportfolioholding_portfolio_portfolio_name : clientportfolioholding -> String // intentionally added for query convenience
		clientportfolioholding_client_client_id : clientportfolioholding -> Integer
		clientportfolioholding_client_client_name : clientportfolioholding -> String // intentionally added for query convenience
		clientportfolioholding_asset_asset_id : clientportfolioholding -> Integer
		clientportfolioholding_asset_asset_name : clientportfolioholding -> String // intentionally added for query convenience
		clientportfolioholding_quantity : clientportfolioholding -> Integer
		clientportfolioholding_purchase_date : clientportfolioholding -> Date
		clientportfolioholding_purchase_price : clientportfolioholding -> Double
		clientportfolioholding_currency_currency_code : clientportfolioholding -> String // intentionally code instead of id for query convenience
	
	observation_equations
		forall c. c.currency_country.country_id = c.currency_country_country_id

		forall a. a.asset_strategy.strategy_id = a.asset_strategy_strategy_id

		forall p. p.portfolio_strategy.strategy_id = p.portfolio_strategy_strategy_id
		forall p. p.portfolio_parent_portfolio.portfolio_id = p.portfolio_parent_portfolio_portfolio_id

		forall t. t.transaction_currency.currency_id = t.transaction_currency_currency_id
		forall t. t.transaction_asset.asset_id = t.transaction_asset_asset_id
		forall t. t.transaction_portfolio.portfolio_id = t.transaction_portfolio_portfolio_id

		forall p. p.clientposition_asset.asset_id = p.clientposition_asset_asset_id
		forall p. p.clientposition_client.client_id = p.clientposition_client_client_id

		forall p. p.clientportfolioholding_asset.asset_id = p.clientportfolioholding_asset_asset_id
		forall p. p.clientportfolioholding_client.client_id = p.clientportfolioholding_client_client_id
		forall p. p.clientportfolioholding_portfolio.portfolio_id = p.clientportfolioholding_portfolio_portfolio_id

} 


query ETL_Cyc = literal : Target -> CycTarget {
 entity
 	
	client -> {from c:client
		 attributes client_id -> c.client_id
			client_name -> c.client_name
			client_description -> c.client_description
	} 

	entity country -> {from c:country
		 attributes country_id -> c.country_id
			country_code -> c.country_code
			country_name -> c.country_name
	} 

entity	currency -> {from c:currency
		 attributes currency_id -> c.currency_id
			currency_code -> c.currency_code
			currency_name -> c.currency_name
			currency_country_country_id -> c.currency_country_country_id
			foreign_keys
	currency_country -> {c -> c.currency_country} 
	
	} 

entity	asset -> {from a:asset
		 attributes asset_id -> a.asset_id
			asset_name -> a.asset_name
			asset_description -> a.asset_description
			asset_strategy_strategy_id -> a.asset_strategy_strategy_id
			foreign_keys
			asset_strategy -> {s -> a.asset_strategy} 
	
	} 

entity	strategy -> {from s:strategy
		 attributes strategy_id -> s.strategy_id
			strategy_name -> s.strategy_name
			strategy_description -> s.strategy_description
	}

entity	portfolio -> {from p:portfolio
		 attributes portfolio_id -> p.portfolio_id
			portfolio_name -> p.portfolio_name
			portfolio_description -> p.portfolio_description
			portfolio_strategy_strategy_id -> p.portfolio_strategy_strategy_id
			portfolio_parent_portfolio_portfolio_id -> p.portfolio_parent_portfolio_portfolio_id
			foreign_keys
			portfolio_parent_portfolio -> {p -> p.portfolio_parent_portfolio} 
	portfolio_strategy -> {s->p.portfolio_strategy} 
	
	} 

entity	transaction -> {from t:transaction
		 attributes transaction_id -> t.transaction_id
			transaction_date -> t.transaction_date
			transaction_portfolio_portfolio_id -> t.transaction_portfolio_portfolio_id
			transaction_portfolio_portfolio_name -> t.transaction_portfolio.portfolio_name
			transaction_asset_asset_id -> t.transaction_asset_asset_id
			transaction_asset_asset_name -> t.transaction_asset.asset_name
			transaction_buy_sell_ind -> t.transaction_buy_sell_ind
			transaction_quantity -> t.transaction_quantity
			transaction_price -> t.transaction_price
			transaction_currency_currency_id -> t.transaction_currency_currency_id
		foreign_keys
			transaction_currency -> {c -> t.transaction_currency} 
	transaction_asset -> {a -> t.transaction_asset} 
	transaction_portfolio -> {p -> t.transaction_portfolio} 
	
	} 

entity	clientposition -> {from p:position
		 attributes clientposition_id -> p.position_id
			clientposition_begin_date -> "1/1/2011" // fake this for now source doesn't have it
			clientposition_end_date -> "1/1/2011" // fake this for now source doesn't have it
			clientposition_client_client_id -> p.position_client.client_id
			clientposition_client_client_name -> p.position_client.client_name
			clientposition_asset_asset_id -> p.position_asset.asset_id
			clientposition_asset_asset_name -> p.position_asset.asset_name
			clientposition_quantity -> p.position_quantity
			clientposition_current_value -> p.position_current_value
			clientposition_current_value_currency_currency_code -> p.position_current_value_currency.currency_code
	 foreign_keys
			clientposition_client -> {c -> p.position_client} 
			clientposition_asset -> {a -> p.position_asset} 
	} 

entity	clientportfolioholding -> {from ph:portfolioholding
		 attributes clientportfolioholding_id -> ph.portfolioholding_holding.holding_id
			clientportfolioholding_begin_date -> ph.portfolioholding_holding.holding_begin_date
			clientportfolioholding_end_date -> ph.portfolioholding_holding.holding_end_date
			clientportfolioholding_asset_asset_id -> ph.portfolioholding_holding.holding_asset.asset_id
			clientportfolioholding_asset_asset_name -> ph.portfolioholding_holding.holding_asset.asset_name
			clientportfolioholding_purchase_price -> ph.portfolioholding_holding.holding_purchase_price
			clientportfolioholding_quantity -> ph.portfolioholding_holding.holding_quantity
			clientportfolioholding_purchase_date -> ph.portfolioholding_holding.holding_purchase_date
			clientportfolioholding_client_client_id -> ph.portfolioholding_client.client_id
			clientportfolioholding_client_client_name -> ph.portfolioholding_client.client_name
			clientportfolioholding_portfolio_portfolio_id -> ph.portfolioholding_portfolio.portfolio_id
			clientportfolioholding_portfolio_portfolio_name -> ph.portfolioholding_portfolio.portfolio_name
			clientportfolioholding_currency_currency_code -> ph.portfolioholding_holding.holding_currency.currency_code
		foreign_keys
			clientportfolioholding_client -> {c -> ph.portfolioholding_client} 
 			clientportfolioholding_asset -> {a -> ph.portfolioholding_holding.holding_asset} 
			clientportfolioholding_portfolio -> {p -> ph.portfolioholding_portfolio} 
	} 

 

} 

instance OutputCyc = eval ETL_Cyc Output 
 
instance OutputCycDistinct = distinct OutputCyc
Keywords:

distinct
quotient
eval
instance_literal
query_literal
sigma
schema_literal
coequalize
transform_literal
typeside_literal

Options:

simplify_names



instance TransFwd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
0?0?1?2?0?1?2
1?3?4?5?3?4?5
2?6?7?8?6?7?8
3?9?10?11?9?10?11
4?12?13?14?12?13?14
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
5Asset11A1?1Asset11A10
6Asset55A5?4Asset55A51
7Asset33A3?7Asset33A32
8Asset99A9?10Asset99A93
9Asset77A7?13Asset77A74
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
10?15?16?17
11?18?19?20
12?21?22?23
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
13EUR?162EuroEUR2Euro10
14JPY?193Japanese YenJPY3Japanese Yen11
15USD?221US DollarUSD1US Dollar12
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency
161sell26/1/2011215.5100513
173buy19/1/2013322.5150715
185sell37/1/2013631.5100614
195buy32/1/2013531.6200614
201buy21/1/2011115.51200513
213sell13/1/2014423.5150715


instance E

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
0?0?1?2?0?2?1
1?3?4?5?3?5?4
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
2?6?7?8?6?7?8
3?9?10?11?9?10?11
4?12?13?14?12?13?14
5?15?16?17?15?16?17
6?18?19?20?18?19?20
7?21?22?23?21?22?23
8?24?25?26?24?25?26
9?27?28?29?27?28?29
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
10?30?31?32?7?30?31?322
11?33?34?35?13?33?34?354
12?36?37?38?16?36?37?385
13?39?40?41?22?39?40?417
14?42?43?44?28?42?43?449
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
15?45?46?47
16?48?49?50
17?51?52?53
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
18?54?46?55?56?54?55?5615
19?57?49?58?59?57?58?5916
20?60?52?61?62?60?61?6217
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency


instance RefInstance

asset
IDasset_descriptionasset_idasset_nameasset_strategy_strategy_idasset_strategy
0Asset55A5519
1Asset99A9321
2Asset66A6422
3Asset1010A10123
4Asset22A2321
5Asset33A3220
6Asset11A1123
7Asset44A4422
8Asset77A7422
9Asset88A8519
country
IDcountry_codecountry_idcountry_name
10US6United States of America
11CH2Switzerland
12JP5Japan
13CN3China
14EU4European Union
15AU1Australia
currency
IDcurrency_codecurrency_country_country_idcurrency_idcurrency_namecurrency_country
16JPY53Japanese Yen12
17EUR42Euro14
18USD61US Dollar10
strategy
IDstrategy_descriptionstrategy_idstrategy_name
19Strategy55Strat5
20Strategy22Strat2
21Strategy33Strat3
22Strategy44Strat4
23Strategy11Strat1


instance HoldPosInstance

client
IDclient_descclient_nmclient_no
0Dick ClientDick2
1Tom ClientTom1
holding
IDholding_asset_asset_idholding_begin_dateholding_client_client_noholding_currency_currency_codeholding_end_dateholding_idholding_portfolio_portfolio_idholding_purchase_dateholding_purchase_priceholding_quantityholding_client
252/1/20132JPY7/1/2013432/1/20131.62000
339/1/20132USD3/1/2014339/1/20132.51500
416/1/20111EUR?0211/1/20115.511001
557/1/20132JPY?1532/1/20131.61000
611/1/20111EUR6/1/2011111/1/20115.512001
position
IDposition_asset_asset_idposition_client_client_noposition_cost_basisposition_cost_basis_currency_currency_codeposition_current_valueposition_current_value_currency_currency_codeposition_idposition_quantityposition_client
752160JPY170JPY21000
811551EUR550EUR11001


instance Output

asset
IDasset_descriptionasset_idasset_nameasset_strategy_strategy_idasset_strategy
0Asset11A1137
1Asset33A3238
2Asset99A9340
3Asset55A5541
4Asset44A4439
5Asset77A7439
6Asset1010A10137
7Asset88A8541
8Asset66A6439
9Asset22A2340
client
IDclient_descriptionclient_idclient_name
10Harry Client3Harry
11Tom Client1Tom
12Dick Client2Dick
country
IDcountry_codecountry_idcountry_name
13EU4European Union
14JP5Japan
15CH2Switzerland
16US6United States of America
17CN3China
18AU1Australia
currency
IDcurrency_codecurrency_country_country_idcurrency_idcurrency_namecurrency_country
19EUR42Euro13
20JPY53Japanese Yen14
21USD61US Dollar16
holding
IDholding_asset_asset_idholding_begin_dateholding_currency_currency_idholding_end_dateholding_idholding_purchase_dateholding_purchase_priceholding_quantityholding_assetholding_currency
2211/1/201126/1/201111/1/20115.51200019
2316/1/20112?021/1/20115.51100019
2439/1/201313/1/201439/1/20132.5150121
2552/1/201337/1/201342/1/20131.6200320
2657/1/20133?152/1/20131.6100320
portfolio
IDportfolio_descriptionportfolio_idportfolio_nameportfolio_parent_portfolio_portfolio_idportfolio_strategy_strategy_idportfolio_parent_portfolioportfolio_strategy
27Portfolio22Port2222738
28Portfolio33Port3212737
29Portfolio11Port1122938
portfolioholding
IDportfolioholding_client_client_idportfolioholding_holding_holding_idportfolioholding_idportfolioholding_portfolio_portfolio_idportfolioholding_clientportfolioholding_holdingportfolioholding_portfolio
3011keygen(1, 1, 1)1112229
3112keygen(2, 1, 1)1112329
3223keygen(3, 2, 3)3122428
3324keygen(4, 2, 3)3122528
3425keygen(5, 2, 3)3122628
position
IDposition_asset_asset_idposition_client_client_idposition_cost_basisposition_cost_basis_currency_currency_idposition_current_valueposition_current_value_currency_currency_idposition_idposition_quantityposition_assetposition_clientposition_cost_basis_currencyposition_current_value_currency
35115512550211000111919
36521603170321003122020
strategy
IDstrategy_descriptionstrategy_idstrategy_name
37Strategy11Strat1
38Strategy22Strat2
39Strategy44Strat4
40Strategy33Strat3
41Strategy55Strat5
transaction
IDtransaction_asset_asset_idtransaction_buy_sell_indtransaction_currency_currency_idtransaction_datetransaction_idtransaction_portfolio_portfolio_idtransaction_pricetransaction_quantitytransaction_assettransaction_currencytransaction_portfolio
423buy19/1/2013322.515012127
433sell13/1/2014423.515012127
443buy19/1/2013322.515012127
453sell13/1/2014423.515012127
463buy19/1/2013322.515012127
473sell13/1/2014423.515012127
485buy32/1/2013531.620032028
495sell37/1/2013631.510032028
505buy32/1/2013531.620032028
515sell37/1/2013631.510032028
525buy32/1/2013531.620032028
535sell37/1/2013631.510032028
541buy21/1/2011115.5120001929
551sell26/1/2011215.510001929
561buy21/1/2011115.5120001929
571sell26/1/2011215.510001929
581buy21/1/2011115.5120001929
591sell26/1/2011215.510001929
603buy19/1/2013322.515012127
613sell13/1/2014423.515012127
623buy19/1/2013322.515012127
633sell13/1/2014423.515012127
643buy19/1/2013322.515012127
653sell13/1/2014423.515012127
665buy32/1/2013531.620032028
675sell37/1/2013631.510032028
685buy32/1/2013531.620032028
695sell37/1/2013631.510032028
705buy32/1/2013531.620032028
715sell37/1/2013631.510032028
721buy21/1/2011115.5120001929
731sell26/1/2011215.510001929
741buy21/1/2011115.5120001929
751sell26/1/2011215.510001929
761buy21/1/2011115.5120001929
771sell26/1/2011215.510001929
783buy19/1/2013322.515012127
793sell13/1/2014423.515012127
803buy19/1/2013322.515012127
813sell13/1/2014423.515012127
823buy19/1/2013322.515012127
833sell13/1/2014423.515012127
845buy32/1/2013531.620032028
855sell37/1/2013631.510032028
865buy32/1/2013531.620032028
875sell37/1/2013631.510032028
885buy32/1/2013531.620032028
895sell37/1/2013631.510032028
901buy21/1/2011115.5120001929
911sell26/1/2011215.510001929
921buy21/1/2011115.5120001929
931sell26/1/2011215.510001929
941buy21/1/2011115.5120001929
951sell26/1/2011215.510001929


instance OutputCyc

asset
IDasset_descriptionasset_idasset_nameasset_strategy_strategy_idasset_strategy
0Asset11A1132
1Asset33A3233
2Asset99A9335
3Asset55A5536
4Asset44A4434
5Asset77A7434
6Asset1010A10132
7Asset88A8536
8Asset66A6434
9Asset22A2335
client
IDclient_descriptionclient_idclient_name
10Harry Client3Harry
11Tom Client1Tom
12Dick Client2Dick
clientportfolioholding
IDclientportfolioholding_asset_asset_idclientportfolioholding_asset_asset_nameclientportfolioholding_begin_dateclientportfolioholding_client_client_idclientportfolioholding_client_client_nameclientportfolioholding_currency_currency_codeclientportfolioholding_end_dateclientportfolioholding_idclientportfolioholding_portfolio_portfolio_idclientportfolioholding_portfolio_portfolio_nameclientportfolioholding_purchase_dateclientportfolioholding_purchase_priceclientportfolioholding_quantityclientportfolioholding_assetclientportfolioholding_clientclientportfolioholding_portfolio
131A11/1/20111TomEUR6/1/201111Port11/1/20115.5120001131
141A16/1/20111TomEUR?021Port11/1/20115.5110001131
153A39/1/20132DickUSD3/1/201433Port39/1/20132.515011230
165A52/1/20132DickJPY7/1/201343Port32/1/20131.620031230
175A57/1/20132DickJPY?153Port32/1/20131.610031230
clientposition
IDclientposition_asset_asset_idclientposition_asset_asset_nameclientposition_begin_dateclientposition_client_client_idclientposition_client_client_nameclientposition_current_valueclientposition_current_value_currency_currency_codeclientposition_end_dateclientposition_idclientposition_quantityclientposition_assetclientposition_client
181A11/1/20111Tom550EUR1/1/20111100011
195A51/1/20112Dick170JPY1/1/20112100312
country
IDcountry_codecountry_idcountry_name
20EU4European Union
21JP5Japan
22CH2Switzerland
23US6United States of America
24CN3China
25AU1Australia
currency
IDcurrency_codecurrency_country_country_idcurrency_idcurrency_namecurrency_country
26EUR42Euro20
27JPY53Japanese Yen21
28USD61US Dollar23
portfolio
IDportfolio_descriptionportfolio_idportfolio_nameportfolio_parent_portfolio_portfolio_idportfolio_strategy_strategy_idportfolio_parent_portfolioportfolio_strategy
29Portfolio22Port2222933
30Portfolio33Port3212932
31Portfolio11Port1123133
strategy
IDstrategy_descriptionstrategy_idstrategy_name
32Strategy11Strat1
33Strategy22Strat2
34Strategy44Strat4
35Strategy33Strat3
36Strategy55Strat5
transaction
IDtransaction_asset_asset_idtransaction_asset_asset_nametransaction_buy_sell_indtransaction_currency_currency_idtransaction_datetransaction_idtransaction_portfolio_portfolio_idtransaction_portfolio_portfolio_nametransaction_pricetransaction_quantitytransaction_assettransaction_currencytransaction_portfolio
373A3buy19/1/201332Port22.515012829
383A3sell13/1/201442Port23.515012829
393A3buy19/1/201332Port22.515012829
403A3sell13/1/201442Port23.515012829
413A3buy19/1/201332Port22.515012829
423A3sell13/1/201442Port23.515012829
435A5buy32/1/201353Port31.620032730
445A5sell37/1/201363Port31.510032730
455A5buy32/1/201353Port31.620032730
465A5sell37/1/201363Port31.510032730
475A5buy32/1/201353Port31.620032730
485A5sell37/1/201363Port31.510032730
491A1buy21/1/201111Port15.5120002631
501A1sell26/1/201121Port15.510002631
511A1buy21/1/201111Port15.5120002631
521A1sell26/1/201121Port15.510002631
531A1buy21/1/201111Port15.5120002631
541A1sell26/1/201121Port15.510002631
553A3buy19/1/201332Port22.515012829
563A3sell13/1/201442Port23.515012829
573A3buy19/1/201332Port22.515012829
583A3sell13/1/201442Port23.515012829
593A3buy19/1/201332Port22.515012829
603A3sell13/1/201442Port23.515012829
615A5buy32/1/201353Port31.620032730
625A5sell37/1/201363Port31.510032730
635A5buy32/1/201353Port31.620032730
645A5sell37/1/201363Port31.510032730
655A5buy32/1/201353Port31.620032730
665A5sell37/1/201363Port31.510032730
671A1buy21/1/201111Port15.5120002631
681A1sell26/1/201121Port15.510002631
691A1buy21/1/201111Port15.5120002631
701A1sell26/1/201121Port15.510002631
711A1buy21/1/201111Port15.5120002631
721A1sell26/1/201121Port15.510002631
733A3buy19/1/201332Port22.515012829
743A3sell13/1/201442Port23.515012829
753A3buy19/1/201332Port22.515012829
763A3sell13/1/201442Port23.515012829
773A3buy19/1/201332Port22.515012829
783A3sell13/1/201442Port23.515012829
795A5buy32/1/201353Port31.620032730
805A5sell37/1/201363Port31.510032730
815A5buy32/1/201353Port31.620032730
825A5sell37/1/201363Port31.510032730
835A5buy32/1/201353Port31.620032730
845A5sell37/1/201363Port31.510032730
851A1buy21/1/201111Port15.5120002631
861A1sell26/1/201121Port15.510002631
871A1buy21/1/201111Port15.5120002631
881A1sell26/1/201121Port15.510002631
891A1buy21/1/201111Port15.5120002631
901A1sell26/1/201121Port15.510002631


instance TransInstance

asset
IDasset_descriptionasset_idasset_name
0Asset11A1
1Asset55A5
2Asset33A3
3Asset99A9
4Asset77A7
currency
IDcurrency_codecurrency_idcurrency_name
5EUR2Euro
6JPY3Japanese Yen
7USD1US Dollar
transaction
IDtransaction_asset_asset_idtransaction_buy_sell_indtransaction_currency_currency_idtransaction_datetransaction_idtransaction_portfolio_portfolio_idtransaction_pricetransaction_quantitytransaction_assettransaction_currency
81sell26/1/2011215.510005
93buy19/1/2013322.515027
105sell37/1/2013631.510016
115buy32/1/2013531.620016
121buy21/1/2011115.5120005
133sell13/1/2014423.515027


instance PortfolioFwd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
01Portfolio11Port11204
12Portfolio33Port32125
22Portfolio22Port22224
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
3Strategy33Strat3Strategy33Strat3
4Strategy22Strat2Strategy22Strat2
5Strategy11Strat1Strategy11Strat1
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency


instance ClientInstance

client
IDclient_descriptionclient_idclient_name
0Tom Client1Tom
1Dick Client2Dick
2Harry Client3Harry


instance RefFwd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
0Strategy55Strat5Strategy55Strat5
1Strategy22Strat2Strategy22Strat2
2Strategy33Strat3Strategy33Strat3
3Strategy44Strat4Strategy44Strat4
4Strategy11Strat1Strategy11Strat1
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
5Asset55A55Asset55A50
6Asset99A93Asset99A92
7Asset66A64Asset66A63
8Asset1010A101Asset1010A104
9Asset22A23Asset22A22
10Asset33A32Asset33A31
11Asset11A11Asset11A14
12Asset44A44Asset44A43
13Asset77A74Asset77A73
14Asset88A85Asset88A80
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
15US6United States of America
16CH2Switzerland
17JP5Japan
18CN3China
19EU4European Union
20AU1Australia
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
21JPY53Japanese YenJPY3Japanese Yen17
22EUR42EuroEUR2Euro19
23USD61US DollarUSD1US Dollar15
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency


instance PortfolioInstance

portfolio
IDportfolio_client_client_idportfolio_descriptionportfolio_idportfolio_nameportfolio_parent_portfolio_portfolio_idportfolio_strategy_strategy_idportfolio_parent_portfolioportfolio_strategy
01Portfolio11Port11204
12Portfolio33Port32125
22Portfolio22Port22224
strategy
IDstrategy_descriptionstrategy_idstrategy_name
3Strategy33Strat3
4Strategy22Strat2
5Strategy11Strat1


instance CoProd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
0Harry Client3HarryHarry ClientHarry3
1Tom Client1TomTom ClientTom1
2Dick Client2DickDick ClientDick2
3Dick Client2DickDick ClientDick2
4Tom Client1TomTom ClientTom1
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
511/1/20111EUR6/1/2011111/1/20115.512001
652/1/20132JPY7/1/2013432/1/20131.62002
739/1/20132USD3/1/2014339/1/20132.51502
816/1/20111EUR?0211/1/20115.511001
957/1/20132JPY?1532/1/20131.61002
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
1052160JPY170JPY21002
1111551EUR550EUR11001
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
122Portfolio22Port2221216
132Portfolio33Port3211217
141Portfolio11Port1121416
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
15?2?3?4?2?3?4
16Strategy22Strat2Strategy22Strat2
17Strategy11Strat1Strategy11Strat1
18?5?6?7?5?6?7
19Strategy44Strat4Strategy44Strat4
20?8?9?10?8?9?10
21Strategy55Strat5Strategy55Strat5
22?11?12?13?11?12?13
23Strategy22Strat2Strategy22Strat2
24?14?15?16?14?15?16
25Strategy11Strat1Strategy11Strat1
26Strategy33Strat3Strategy33Strat3
27Strategy33Strat3Strategy33Strat3
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
28Asset11A1?3Asset11A115
29Asset33A3?6Asset33A318
30Asset99A9?9Asset99A920
31Asset55A55Asset55A521
32Asset44A44Asset44A419
33Asset77A7?12Asset77A722
34Asset33A32Asset33A323
35Asset55A5?15Asset55A524
36Asset1010A101Asset1010A1025
37Asset77A74Asset77A719
38Asset99A93Asset99A926
39Asset88A85Asset88A821
40Asset66A64Asset66A619
41Asset11A11Asset11A125
42Asset22A23Asset22A226
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
43?17?18?19
44JP5Japan
45CH2Switzerland
46?20?21?22
47US6United States of America
48?23?24?25
49EU4European Union
50CN3China
51AU1Australia
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
52EUR?182EuroEUR2Euro43
53JPY53Japanese YenJPY3Japanese Yen44
54USD?211US DollarUSD1US Dollar46
55JPY?243Japanese YenJPY3Japanese Yen48
56USD61US DollarUSD1US Dollar47
57EUR42EuroEUR2Euro49
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency
581buy21/1/2011115.512002852
593buy19/1/2013322.51502954
603sell13/1/2014423.51502954
615buy32/1/2013531.62003555
621sell26/1/2011215.51002852
635sell37/1/2013631.51003555


instance HoldPosFwd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
0Dick Client2DickDick ClientDick2
1Tom Client1TomTom ClientTom1
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
252/1/20132JPY7/1/2013432/1/20131.62000
316/1/20111EUR?0211/1/20115.511001
457/1/20132JPY?1532/1/20131.61000
539/1/20132USD3/1/2014339/1/20132.51500
611/1/20111EUR6/1/2011111/1/20115.512001
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
752160JPY170JPY21000
811551EUR550EUR11001
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency


instance ColimitInstance

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
0Harry Client3HarryHarry ClientHarry3
1Tom Client1TomTom ClientTom1
2Dick Client2DickDick ClientDick2
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
311/1/20111EUR6/1/2011111/1/20115.512001
452/1/20132JPY7/1/2013432/1/20131.62002
539/1/20132USD3/1/2014339/1/20132.51502
657/1/20132JPY?0532/1/20131.61002
716/1/20111EUR?1211/1/20115.511001
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
852160JPY170JPY21002
911551EUR550EUR11001
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
102Portfolio22Port2221014
112Portfolio33Port3211013
121Portfolio11Port1121214
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
13Strategy11Strat1Strategy11Strat1
14Strategy22Strat2Strategy22Strat2
15Strategy44Strat4Strategy44Strat4
16Strategy33Strat3Strategy33Strat3
17Strategy55Strat5Strategy55Strat5
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
18Asset11A11Asset11A113
19Asset33A32Asset33A314
20Asset99A93Asset99A916
21Asset55A55Asset55A517
22Asset44A44Asset44A415
23Asset77A74Asset77A715
24Asset1010A101Asset1010A1013
25Asset88A85Asset88A817
26Asset66A64Asset66A615
27Asset22A23Asset22A216
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
28EU4European Union
29JP5Japan
30CH2Switzerland
31US6United States of America
32CN3China
33AU1Australia
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
34EUR42EuroEUR2Euro28
35JPY53Japanese YenJPY3Japanese Yen29
36USD61US DollarUSD1US Dollar31
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency
371buy21/1/2011115.512001834
383buy19/1/2013322.51501936
391sell26/1/2011215.51001834
403sell13/1/2014423.51501936
415buy32/1/2013531.62002135
425sell37/1/2013631.51002135


instance OutputCycDistinct

asset
IDasset_descriptionasset_idasset_nameasset_strategy_strategy_idasset_strategy
0Asset11A1132
1Asset33A3233
2Asset99A9335
3Asset55A5536
4Asset44A4434
5Asset77A7434
6Asset1010A10132
7Asset88A8536
8Asset66A6434
9Asset22A2335
client
IDclient_descriptionclient_idclient_name
10Harry Client3Harry
11Tom Client1Tom
12Dick Client2Dick
clientportfolioholding
IDclientportfolioholding_asset_asset_idclientportfolioholding_asset_asset_nameclientportfolioholding_begin_dateclientportfolioholding_client_client_idclientportfolioholding_client_client_nameclientportfolioholding_currency_currency_codeclientportfolioholding_end_dateclientportfolioholding_idclientportfolioholding_portfolio_portfolio_idclientportfolioholding_portfolio_portfolio_nameclientportfolioholding_purchase_dateclientportfolioholding_purchase_priceclientportfolioholding_quantityclientportfolioholding_assetclientportfolioholding_clientclientportfolioholding_portfolio
131A11/1/20111TomEUR6/1/201111Port11/1/20115.5120001131
141A16/1/20111TomEUR?021Port11/1/20115.5110001131
153A39/1/20132DickUSD3/1/201433Port39/1/20132.515011230
165A52/1/20132DickJPY7/1/201343Port32/1/20131.620031230
175A57/1/20132DickJPY?153Port32/1/20131.610031230
clientposition
IDclientposition_asset_asset_idclientposition_asset_asset_nameclientposition_begin_dateclientposition_client_client_idclientposition_client_client_nameclientposition_current_valueclientposition_current_value_currency_currency_codeclientposition_end_dateclientposition_idclientposition_quantityclientposition_assetclientposition_client
181A11/1/20111Tom550EUR1/1/20111100011
195A51/1/20112Dick170JPY1/1/20112100312
country
IDcountry_codecountry_idcountry_name
20EU4European Union
21JP5Japan
22CH2Switzerland
23US6United States of America
24CN3China
25AU1Australia
currency
IDcurrency_codecurrency_country_country_idcurrency_idcurrency_namecurrency_country
26EUR42Euro20
27JPY53Japanese Yen21
28USD61US Dollar23
portfolio
IDportfolio_descriptionportfolio_idportfolio_nameportfolio_parent_portfolio_portfolio_idportfolio_strategy_strategy_idportfolio_parent_portfolioportfolio_strategy
29Portfolio22Port2222933
30Portfolio33Port3212932
31Portfolio11Port1123133
strategy
IDstrategy_descriptionstrategy_idstrategy_name
32Strategy11Strat1
33Strategy22Strat2
34Strategy44Strat4
35Strategy33Strat3
36Strategy55Strat5
transaction
IDtransaction_asset_asset_idtransaction_asset_asset_nametransaction_buy_sell_indtransaction_currency_currency_idtransaction_datetransaction_idtransaction_portfolio_portfolio_idtransaction_portfolio_portfolio_nametransaction_pricetransaction_quantitytransaction_assettransaction_currencytransaction_portfolio
373A3buy19/1/201332Port22.515012829
383A3sell13/1/201442Port23.515012829
395A5buy32/1/201353Port31.620032730
405A5sell37/1/201363Port31.510032730
411A1buy21/1/201111Port15.5120002631
421A1sell26/1/201121Port15.510002631


instance ClientFwd

Client_client__HoldPos_client
IDClient_client_client_descriptionClient_client_client_idClient_client_client_nameHoldPos_client_client_descHoldPos_client_client_nmHoldPos_client_client_no
0Tom Client1TomTom ClientTom1
1Dick Client2DickDick ClientDick2
2Harry Client3HarryHarry ClientHarry3
HoldPos_holding
IDHoldPos_holding_holding_asset_asset_idHoldPos_holding_holding_begin_dateHoldPos_holding_holding_client_client_noHoldPos_holding_holding_currency_currency_codeHoldPos_holding_holding_end_dateHoldPos_holding_holding_idHoldPos_holding_holding_portfolio_portfolio_idHoldPos_holding_holding_purchase_dateHoldPos_holding_holding_purchase_priceHoldPos_holding_holding_quantityHoldPos_holding_holding_client
HoldPos_position
IDHoldPos_position_position_asset_asset_idHoldPos_position_position_client_client_noHoldPos_position_position_cost_basisHoldPos_position_position_cost_basis_currency_currency_codeHoldPos_position_position_current_valueHoldPos_position_position_current_value_currency_currency_codeHoldPos_position_position_idHoldPos_position_position_quantityHoldPos_position_position_client
Portfolio_portfolio
IDPortfolio_portfolio_portfolio_client_client_idPortfolio_portfolio_portfolio_descriptionPortfolio_portfolio_portfolio_idPortfolio_portfolio_portfolio_namePortfolio_portfolio_portfolio_parent_portfolio_portfolio_idPortfolio_portfolio_portfolio_strategy_strategy_idPortfolio_portfolio_portfolio_parent_portfolioPortfolio_portfolio_portfolio_strategy
Portfolio_strategy__Ref_strategy
IDPortfolio_strategy_strategy_descriptionPortfolio_strategy_strategy_idPortfolio_strategy_strategy_nameRef_strategy_strategy_descriptionRef_strategy_strategy_idRef_strategy_strategy_name
Ref_asset__Trans_asset
IDRef_asset_asset_descriptionRef_asset_asset_idRef_asset_asset_nameRef_asset_asset_strategy_strategy_idTrans_asset_asset_descriptionTrans_asset_asset_idTrans_asset_asset_nameRef_asset_asset_strategy
Ref_country
IDRef_country_country_codeRef_country_country_idRef_country_country_name
Ref_currency__Trans_currency
IDRef_currency_currency_codeRef_currency_currency_country_country_idRef_currency_currency_idRef_currency_currency_nameTrans_currency_currency_codeTrans_currency_currency_idTrans_currency_currency_nameRef_currency_currency_country
Trans_transaction
IDTrans_transaction_transaction_asset_asset_idTrans_transaction_transaction_buy_sell_indTrans_transaction_transaction_currency_currency_idTrans_transaction_transaction_dateTrans_transaction_transaction_idTrans_transaction_transaction_portfolio_portfolio_idTrans_transaction_transaction_priceTrans_transaction_transaction_quantityTrans_transaction_transaction_assetTrans_transaction_transaction_currency