How to store a custom checkout field in the database?

So how can I add fields and store their values in database?

You should implement a custom checkout field as a customer or an address attribute.

A post was split to a new topic: What xml file should I add to layout folder and what is the reference container to add a custom field to the checkout page?