Best way to store/organise empty data in database?

Hi there,

I have a form that collects some user data.

I have a radio button option for the user to select if they are entering personal or business details.

If it is a business, they will enter company name, number of employees and industry. If they are a personal user, they do not need to enter this.

My question is, if they are a personal user, what data should I enter into the company, number of employees and industry columns by default as these columns will surely exist in my table from business users.

Should I just set the default entry to be “n/a” or something similar?

Any suggestions would be great, thanks

null

Not the actual word as a string, but a null value.
There is the option to allow any column of any data type to accept null and you may set it as a default if you wish.


Note here description and active allow null as a value. description has null as its default.

1 Like

Thanks for the reply.

I see, that makes sense, thank you.

I guess when I return the results from a row, I will output the null as something like n/a? For example if I returned results that included data in this column and without data, it would use something descriptive?

If you need to display something for empty values, you can.
For example in PHP you may have:-

if(!$this->companyName){ $this->companyName = 'N\A' ;}

Or if your semantics demand the content is blank, you can use CSS to add pseudo content. Eg.

td:empty::after {
    content: 'N\A' ;
}

What you display for blank data (if anything) is entirely up to you.

1 Like

Thank you, that helps a lot :slight_smile:

Really appreciate your help

you might also consider using a supertable/subtable structure

people and companies as separate subtype tables, with attributes in each that pertain only to that subtype, with an overall supertype entities table, containing common attributes

however, if it’s just three columns, i might just stick with one table, and use NULLs

you can use the COALESCE sql function to generate the ‘N/A’ values

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.