Home / SIDU


    Optional sidu_fk table

    2013-01-02 00:00
    81351   0   4

    sidu_fk is an optional table helps you and SIDU work better for foreign keys, enum, or meta data.

    SIDU will produce drop-down select menu for data edit window based on instruction in table sidu_fk;

    If sidu_fk has not been created or data not found in sidu_fk, SIDU will still produce drop-down select menu for MysQL enums or PostgreSQL foreign keys;

    If select options are more than 200 values, SIDU will use input text field instead.

    1. create sidu_fk table in each database
    CREATE TABLE sidu_fk (
    tab varchar(80) NOT NULL,
    col varchar(80) NOT NULL,
    ref_tab varchar(80) NOT NULL,
    ref_cols varchar(255) NOT NULL,
    where_sort varchar(255),
    PRIMARY KEY (tab,col)
    );


    2. Example one: foreign key

    table: customer(cid,title_id,name,age,...)
    table: title(title_id,title_name)

    sidu_fk(tab,col,ref_tab,ref_cols,where_sort)
    eg. sidu_fk('customer','title_id','title','title_id;title_name','order by 1')

    3. Example two: meta table

    table: invoice(id,status,ccy,ts,amt,...)
    table: meta_tab(meta,col,var)
    eg. meta_tab('ccy','1','USD'),('ccy','2','EUR')
    eg. meta_tab('status','1','New'),('status','2','Paid')

    sidu_fk(tab,col,ref_tab,ref_cols,where_sort)
    eg. sidu_fk('invoice','ccy','meta_tab','col;var',"where meta='ccy'")

    4. How sidu_fk improves the display of PosgreSQL system catalog tables:

    This is part of a system catalog table: pg_class
    pg_class

    Now we add several rows into public.sidu_fk
    pg_class

    Now let's show the pg_class table in SIDU again:
    pg_class
    Back « How to install databases
    Next » SIDU hotkey list

    Comments

    Leave a commentEdit comment

    Category