The value that is displayed in the reference field comes from the Main field of the specific item in the referenced collection. The actual value that is stored in the database is the ID of the referenced item (in other words, the value in the ID system field of the referenced collection).
https://support.wix.com/en/article/about-reference-fields-in-database-collections
Note that you cannot connect any element directly to a multiple-item reference field.
https://support.wix.com/en/article/working-with-multiple-item-reference-fields
You can read about using reference fields here.
https://support.wix.com/en/article/about-referencing-multiple-items-in-one-field
Finally, see these previous posts for more info.
https://www.wix.com/corvid/forum/community-discussion/import-data-reference-field
https://www.wix.com/corvid/forum/community-discussion/reference-fields-in-dataset