Friday, August 1, 2008

Constrain SQL like pattern for Commission Rate lookup


SQL Like allow pattern match but normally return multiple rows. If you have one
commision rate for a pattern, carefully specified pattern will allow look up to
return just one value without the ambiguity as shown here:
FSMI% vs. FSMIU%

In general, we need to consider the following:

(1) Clearly define Bloomberg symbol as 2 charaters key and Add GMO prefix to
generate external security id pattern. (GMO_EXT_SEC_ID_PATN_DEF).
In particular, Commission Rate table GMO_BROKER_COMM need to have Foreign key
constraints from GMO_EXT_SEC_ID_PATN_DEF to avoid invalid security.

(2) GMO_BROKER_COMM need to have a trigger constraint to make sure the following
will not return more than one row:
select * from GMO_BROKER_COMM2 where
(EXT_SEC_ID_PATN like @EXT_SEC_ID_PATN or
@EXT_SEC_ID_PATN like EXT_SEC_ID_PATN)

in particular, if we need to have both FSMI% and FSMIU%, we will need to span out
even with duplcation rates:
FSMIH% 2.95
FSMIG% 2.95
FSMIZ% 2.95

FSMIU% 4.95

This will eliminate ambiguity.

(3) We need [BB_SYMBOL] [char](2) NOT NULL to keep space for Bloomberg symbol
and that will avoid some ambiguity like FBC % vs. FBCC%

(4) FBC % vs. FBC%
FB C -- SET50 FUTURES maps to FBC %
F BC -- CORN FUTURE maps to FBC%
we currenlty do not have commission rate for FBC %. But we need to be
careful when enter rates in the future

(5) The following is the SQL used in Mid-Tier:
select * from GMO_BROKER_COMM where @ext_sec_id like EXT_SEC_ID_PATN



No comments: