How to add selected data in RG to database

I have a product page where users can choose variations such as size and colour. But how can i store the selected variations into the database? I have tried using dropdown instead of buttons in a RG but it is the same

image