What is the difference between uvm_config_db and uvm_resource_db?

In reply to tfitz:

Hi Tom,
I tried one example with uvm_resource_db.
But it is not working as you explained for uvm_resource_db during build_phase.
In uvm_resource_db also top hierarchy win during build_phase.

class my_agent extends uvm_agent;
  `uvm_component_utils (my_agent)
  int var1;
  function new (string name = "my_agent", uvm_component parent = null);
   super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    if(!uvm_resource_db #(int)::read_by_name("", "var1", var1, this))
      `uvm_error ("GET-FAIL", "not able to get value")
    else 
      `uvm_info ("GET-PASS", $sformatf("var1=%0d", var1), UVM_NONE)
  endfunction
endclass

/////////////////
class my_env extends uvm_env;
  `uvm_component_utils (my_env)
  int var1;
  my_agent agnt;
  function new (string name = "my_env", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    agnt = my_agent::type_id::create("angt", this);
    var1 = 60;
    uvm_resource_db #(int)::set("*", "var1", var1, this);
    `uvm_info ("SET", $sformatf("From ENV=%0d", var1), UVM_NONE)
  endfunction
endclass

/////////////////
class my_test extends uvm_test;
  `uvm_component_utils (my_test)
  int var1;
  my_env env;
  function new (string name = "my_test", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    env = my_env::type_id::create("env", this);
    var1 = 70;
    uvm_resource_db #(int)::set("*", "var1", var1, this);
    `uvm_info ("SET", $sformatf("From TEST=%0d", var1), UVM_NONE) 
  endfunction
  task run_phase (uvm_phase phase);
    phase.raise_objection(this);
    #500;
    phase.drop_objection(this);
  endtask
endclass

///////////////
module top();
  initial begin
    run_test("my_test");
  end
endmodule

//Output:
//UVM_INFO @ 0: reporter [RNTST] Running test my_test...
//UVM_INFO testbench.sv(15) @ 0: uvm_test_top [SET] From TEST=70
//UVM_INFO design.sv(36) @ 0: uvm_test_top.env [SET] From ENV=60
//UVM_INFO design.sv(14) @ 0: uvm_test_top.env.angt [GET-PASS] var1=70
//UVM_INFO /apps/vcsmx/etc/uvm-1.1/src/base/uvm_objection.svh(1267) @ 500: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase

Here I set value 70 from test, 60 from env, and getting value 70 in agent instead of 60.
Can you please explain what is wrong I am doing here?