1 wic_table_object
Two new tables (plus a labels support) are added to the logical table dictionary.
-
wic_table_check_constraints
, is added to allow non database checks writen directly in javascript. The motivation is:- Provide a new javascript plain syntax (not JUEL)
- Some constraints can not be enforced in database cause interfaces may need to do some operations not allowed from clients.
-
Avoid to modify existing table
wic_jdic_clientchk
that will remain unmodified
-
wic_table_check_constraints_labels
with the localized lables for the check to avoid use the general lables table. -
wic_table_foreign_keys
, is added to allow to enforce application foreign keys. The motivation is:- Some physical constraints can't be enforced some times for performance degradation
-
Avoid to use existing table for similar purpose
wic_jdic_softref?????
Schema proposal:
Copy
<table name='wic_table_check_constraints_labels'> <!-- COLUMNS --> <column name='label_code' type='char' size='40'required='y'info='Code of label'/> <column name='locale' type='char' size='2' required='y'info='Language en,es,ca...' /> <column name='label_name' type='varchar' size='255' required='y'info='Description of label'/> <!-- INDEXES --> <index name='u_wic_table_check_constraints_labels1' columns='label_code,locale' unique='y' /> </table> <table name='wic_table_check_constraints'> <!-- COLUMNS --> <column name='check_id' type='serial' required='y' info='Identifier'/> <column name='tab_name' type='char' size='48'required='y' info='Refer to wic_table_object'/> <column name='label_code' type='char' size='40'required='y' info='Refer to wic_table_check_constraints_labels'/> <column name='constraint_data' type='lvarchar' size='512' required='y' info='Javascript plain syntax'/> <column name='user_created' type='char' size='20' default='user'required='y' /> <column name='date_created' type='datetime' size='year to second' default='current' required='y' /> <column name='user_updated' type='char' size='20' default='user'required='y' /> <column name='date_updated' type='datetime' size='year to second' default='current' required='y' /> <!-- INDEXES --> <primary name='p_wic_table_check_constraints' columns='check_id' /> <!-- FOREIGN KEYS --> <foreign name='f_wic_table_check_constraints1' columns='tab_name' references='wic_table_object' refcols='tab_name' ondeletecascade='y' /> <foreign name='f_wic_table_check_constraints2' columns='label_code' references='wic_table_check_constraints_labels' refcols='label_code' /> </table> <table name='wic_table_foreign_keys'> <!-- COLUMNS --> <column name='fk_id'type='serial' required='y' info='Identifier'/> <column name='tab_name' type='char' size='48'required='y' info='Refer to wic_table_object'/> <column name='fk_cols' type='varchar'size='80'required='y' info='Columns used at fk'/> <column name='pk_table' type='char' size='48'required='y' info='Destination table'/> <!-- Needed ?? --> <column name='pk_cols' type='varchar'size='80'required='y' info='Columns used at destination table'/> <column name='user_created' type='char' size='20' default='user'required='y' /> <column name='date_created' type='datetime' size='year to second' default='current' required='y' /> <column name='user_updated' type='char' size='20' default='user'required='y' /> <column name='date_updated' type='datetime' size='year to second' default='current' required='y' /> <!-- INDEXES --> <primary name='p_wic_table_foreign_keys' columns='fk_id' /> <unique name='u_wic_table_foreign_keys1' columns='tab_name,pk_table'/> <!-- FOREIGN KEYS --> <foreign name='f_wic_table_foreign_keys1' columns='tab_name' references='wic_table_object' refcols='tab_name' ondeletecascade='y' /> </table>
Most common Database checks
Copy
<check name='c_pos_warehouse1'> <constraint> whs_state IN ('A','B') </constraint> </check> <check name='c_pos_printer_tickets_1'> <constraint><![CDATA[ (print_template_type IN(0,1,2,3)) </constraint> </check> <check name='c_pos_payment1'> <constraint><![CDATA[ ((pay_type = 'VOUCHER' AND voucher_type IS NOT NULL) OR (pay_type != 'VOUCHER')) </constraint> </check> <check name='c_pos_rate_item1'> <constraint><![CDATA[ (item_dtouni <= 100) OR (item_dtouni >= -100) </constraint> </check> <check name='c_pos_promotion4'> <constraint><![CDATA[ from_price >= 0 </constraint> </check> <!-- Only one of this columns must be informed product, tag, home, category, provider, brand --> <check name='c_pos_ecom_card_items1'> <constraint> ((product_id IS NOT NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NOT NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NOT NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NOT NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NOT NULL AND provider_id IS NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NOT NULL AND brand_id IS NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NOT NULL) OR (product_id IS NULL AND tag_id IS NULL AND home_id IS NULL AND page_id IS NULL AND category_id IS NULL AND provider_id IS NULL AND brand_id IS NULL) ) </constraint> </check>
Rare Database checks
Copy
<check name='c_ccalhorl1'> <constraint><![CDATA[ (((horini != '00:00' AND horini IS NOT NULL) OR (horfin != '00:00' AND horfin IS NOT NULL)) AND (hornum >0 AND hornum IS NOT NULL)) OR (horini IS NULL AND horfin IS NULL AND hornum IS NULL) </constraint> </check> <check name='c_cgconoth2'> <constraint> <extend from='year' to='day'>date_created</extend> = <extend from='year' to='day'>date_updated</extend> </constraint> </check> <check name='c_csalprog1'> <constraint> <substr>agrupa, 1, 1</substr> BETWEEN 'A' AND 'Z' </constraint> </check> <!-- Ifx explain: c_csalprog1 ((SUBSTR (agrupa ,1 ,1 )>= 'A' ) AND (SUBSTR (agrupa ,1 ,1 )<= 'Z' ) ) --> <check name='c_csepadom2'> <constraint> ((estado = 1 AND file_data IS NULL AND numope = 0) OR (estado IN (2, 3) AND (file_data IS NOT NULL OR fecfir = <mdy m='10' d='31' y='2009'/>))) </constraint> </check> <check name='c_cserdoch2'> <constraint> (lenjus BETWEEN 0 AND (20-<length>codigo</length>)) </constraint> </check> <check name='c_cserdoch6'> <constraint> <substr>codigo, <length>codigo</length>, 1</substr> IN ('-','/','.') </constraint> </check> <check name='c_cserdoch6'> <constraint> codigo[1] IN ('-','/','.') </constraint> </check> <check name='c_galmubim2'> <constraint> horfin >= horini </constraint> </check> <check name='c_gcomacuh7'> <constraint> (impant + CASE WHEN impant_ntax IS NULL THEN 0 ELSE impant_ntax END) = 0 OR (impant + CASE WHEN impant_ntax IS NULL THEN 0 ELSE impant_ntax END) <= imptot </constraint> </check>