Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
212,081 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
212,081 Points

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