Best Database Design Practices: Storing Rows and Numbers in a Single Column

Create a data driven web application. Just how the external interface is structured, metadata that is stored as part of the database is defined. Often there is one design consideration: how to store values ​​that can take different types of data. For example, the input required from users is defined in a table measurement. The default dimension value can be string, int, or double depending on the definition of the dimension.

I have three possible solutions: Option 1: Keep all the default settings like varchar, and castto the type of on-the-fly.

Option 2: Create table columns for each data type and store null values ​​in columns that are not applicable.

Option 3. Create separate tables to store values ​​for each data type.

What will be the right and professional way to handle this.

designoptions

+4
source share

All Articles