Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6862979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:43:36+00:00 2026-05-27T02:43:36+00:00

I’m setting all fields to nullable types where the back-end database fields they correspond

  • 0

I’m setting all fields to nullable types where the back-end database fields they correspond to allow nulls. Good? Bad?


The long version:

It works just fine, I just feel like I might be abusing the fact that I can make stuff nullable.

Basically it’s an internal application for employee management that ties into our SQL database. I’m using a three layer structure, from presentation to back-end: Business Objects –> Business Logic –> Data Access.

For my Employee object, I have the following fields:

    public class Employee : Person
    {
       private EmployeeTitle? _employeeTitle = null;  //enum
       private EmployeeType _employeeType;  //enum
       private DateTime _startDate;
       private DateTime? _endDate = null;
       private EmployeeInsuranceRecord _employeeInsuranceRecord = new EmployeeInsuranceRecord();

       //...
    }

    public class EmployeeInsuranceRecord
    {
       private int? _employeeInsuranceRecordID = null;
       private string _alienRegistrationNumber = null;
       private string _healthInsuranceNumber = null;
       private string _unemploymentInsuranceNumber = null;
       private string _welfarePensionNumber = null;
       private DateTime? _insuranceAcquiredDate = null;

       //...
    }

And in my database:

  • EmployeeTitleID allows nulls. An employee may start in a trial period for example, without a set job title.

  • EmployeeTypeID does NOT allow nulls. Even if an employee is a guest or on a trial period, this must be explicitly selected for record purposes.

  • StartDate does NOT allow nulls. If someone is going into the database, we need to know when they started.

  • EndDate however, does allow nulls. Anyone currently employed doesn’t have an EndDate yet.

  • I instantiate an EmployeeInsuranceRecord object on Employee instantiation, but each field within EmployeeInsuranceRecord is nullable because the EmployeeInsuranceRecords go into a separate table linked via an ID, therefore an Employee can exist without an EmployeeInsuranceRecord (common for people just starting, still in the initial paperwork process). By instantiating the EmployeeInsuranceRecord from the get-go, I can keep my presentation layer cleaner by not having the instantiate any classes there. This has no impact on performance, given the small scale we’re working with.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:43:37+00:00Added an answer on May 27, 2026 at 2:43 am

    One annoyance of nulls is the coding overhead to keep checking for null before dereferencing / consumption of the value – you will probably need to use a bunch of static extension methods to make your life easier.

    But much better to use null than to kluge a ‘magic value’ like DateTime.MinValue etc – this not only corrupts data but may pose problems when persisting to the database if you forget to map it back to null.

    As you describe, some of the values become mandatory as they are ‘state’ dependent (e.g. EndDate is required when the employee resigns / retires / is fired). You need to split out your validation strategy based on this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.