Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Modifying Data with SQL Adding Data to a Database Adding a Row to a Table

Columns that are able to have null values

Hi,

I wonder there are any rules on what kind of column should have a value present or can have NULL value. Is it database designers that can control over it when they create database or there are specific type of values we need to know to distinguish those two different kinds?

1 Answer

Steven Parker
Steven Parker
231,269 Points

The decision to allow NULL or not is part of the design. Any column that serves as an index, identifier, or provides a foreign key for relationships will be designed to not allow NULL values.

Otherwise, it becomes a decision based on what makes sense for the kind of data being stored in the column. A table of poll responses, for example, might use NULL to represent "no answer" to a question.

But how can we know which one is allowed and which one is not?

Steven Parker
Steven Parker
231,269 Points

As a designer, you get to decide when to allow them based on what you are using each column for.