[GIS] *Value relation* widget in QGIS

fields-attributesqgiswidget

I cannot understand what the Value Relation widget of the Fields menu in QGIS actually does.

For example: I have a point layer with some columns (ID, value1…) and a table (so just a dbf file) with other values (ID, valueA,…). If I open the Fields menu of the point layer I can set some options for the selected column: Layer (set to table.dbf), Key column (set to ID) and Value column (set to valueA).

Now, if I create a new point, it appears in the row of the widget column a dropdown menu where I can choose the valueA of the table.dbf. And that's ok.

But, what is the meaning of the Key column?

Does someone have an explanation for that? Am I missing something?

Best Answer

Key column is a value, that is saved to the field and replaces previous value. The idea is that each key corresponds to value, that you see in the drop-down menu.

EDIT: Imagine a simple table:

Key | Value
1   | Apple
2   | Pear
3   | Passion fruit

Value relation enables you to select "apple" in a drop-down, but save value "1" (the key) to the field. As you can imagine, this can be very useful in relation DBs, such as PostgreSQL.

Related Question