First thing to remember that lcr_id field is the one to link all three tables together. Let's say that you want to create a lcr to route international call starting with 011:
1) Create a row in lcr_gw table with id = 4, lcr_id = 3 and gateway IP etc.
2) Then create a row in lcr_rule table with id =2, lcr_id = 3 and prefix = 011
3) Then create a row in lcr_rule_target table to glue the gateway and prefix together like this: lcr_id =3, gw_id=4 (Match the id value in lcr_gw table), rule_id = 2 (Match the id in lcr_rule table) also rest of the fields like priority etc.