WEBVTT

1
00:00:00.140 --> 00:00:07.140
Hello. Welcome to KnowledgeCity's course on Microsoft Access 2021, Intermediate.

2
00:00:07.140 --> 00:00:13.140
My name is John Varan, and in these lessons, you will learn about database design principles.

3
00:00:13.140 --> 00:00:21.140
In this lesson, I will show you about the difference between null and empty values and how to properly work with them.

4
00:00:21.140 --> 00:00:26.140
A term that you will encounter often when working with databases is null.

5
00:00:26.140 --> 00:00:31.140
Within the context of a database, a null value usually means that there is no value.

6
00:00:31.140 --> 00:00:34.140
It is the absence of a value.

7
00:00:34.140 --> 00:00:38.140
This is obviously only applicable to columns that are not required.

8
00:00:38.140 --> 00:00:44.140
As a required column, by definition, means that it cannot have a null value.

9
00:00:44.140 --> 00:00:48.140
However, in some cases, things get a little more complicated.

10
00:00:48.140 --> 00:00:54.140
Sometimes a null can also represent the idea that the value exists but is unknown.

11
00:00:54.140 --> 00:01:03.140
So therefore, a null usually means the value doesn't exist, but sometimes it can mean the value might exist but is currently unknown.

12
00:01:03.140 --> 00:01:14.140
To make things even more confusing, this definition can mean different things based on the data type of the column and also what it represents in the real world.

13
00:01:15.140 --> 00:01:20.140
Let's look at these different scenarios so we can try to make sense of them and clear things up.

14
00:01:20.140 --> 00:01:29.890
Let me just create a sample table here, and I'll just call it sample.

15
00:01:29.890 --> 00:01:39.140
So first, let's look at the case where the data type is a date.

16
00:01:39.140 --> 00:01:46.280
For example, it could represent a date of birth, and this will be a date time.

17
00:01:49.040 --> 00:01:58.040
If this table holds a list of people, then it's logical that null would represent that the date of birth exists but is not known.

18
00:01:58.040 --> 00:02:05.040
Obviously, that's because everybody has a birth date, so the concept of the birth date not existing would not make sense.

19
00:02:05.040 --> 00:02:17.040
However, if this table is used to hold something like a list of clients, which could be a mix of real people and companies, then the null could represent that the date of birth does not exist.

20
00:02:17.040 --> 00:02:22.040
For a company or that it does exist but is not known for a person.

21
00:02:22.040 --> 00:02:29.040
As you can see, the context of what the data represents in the real world affects the definition of null.

22
00:02:29.040 --> 00:02:33.040
Next, let's look at an example where the data type is a number.

23
00:02:33.040 --> 00:02:43.560
Rename this to number of orders and make this type number.

24
00:02:44.560 --> 00:02:50.560
In this case, the value we put in here represents the number of orders placed by a client.

25
00:02:50.560 --> 00:03:00.560
This is a little different from the data type date time case because while there isn't a date to represent nothing for numbers, there is.

26
00:03:00.560 --> 00:03:02.560
We can use zero.

27
00:03:02.560 --> 00:03:12.560
That means in this situation, a null should mean that the number of orders is unknown while a value of zero should mean that the client has no orders.

28
00:03:12.560 --> 00:03:17.560
I say should because that's how proper database design should be.

29
00:03:17.560 --> 00:03:24.560
But it can also be common practice for people to leave this value as null when there are no orders.

30
00:03:24.560 --> 00:03:32.560
While doing this isn't necessarily wrong, it does result in losing the distinction between the value being zero and unknown.

31
00:03:32.560 --> 00:03:39.560
It is more clear to maintain this distinction in case it would be needed in the future for queries and reports.

32
00:03:40.560 --> 00:03:44.560
Finally, let's look at an example of a string data type.

33
00:03:44.560 --> 00:03:48.560
This can be referred to by different names depending on the database you're using.

34
00:03:48.560 --> 00:03:53.560
String, text, varchar, nvarchar, and others.

35
00:03:53.560 --> 00:03:58.560
In Microsoft Access, it is called either short text or long text.

36
00:03:58.560 --> 00:04:02.560
Both of those behave the same for the purposes of this example.

37
00:04:03.560 --> 00:04:13.560
So let's say this column is a middle name and we'll use short text.

38
00:04:13.560 --> 00:04:16.560
In this case, the column represents a middle name.

39
00:04:16.560 --> 00:04:25.560
A null value here would represent that the person's middle name is not known or that it's unknown whether they have a middle name.

40
00:04:25.560 --> 00:04:31.560
An empty string would indicate that it is known that the person does not have a middle name.

41
00:04:32.560 --> 00:04:41.560
An empty string is analogous to the value of zero for numbers, but it looks more confusing because there's no visual symbol to represent it.

42
00:04:41.560 --> 00:04:50.560
And unfortunately, Microsoft Access displays both empty strings and nulls the same way, just as a blank.

43
00:04:50.560 --> 00:04:54.560
Hopefully, it is now clear what null means in different contexts.

44
00:04:54.560 --> 00:04:59.560
If not, try to go back and repeat some of the examples on your own.

45
00:05:00.560 --> 00:05:01.560
Thanks for watching.

46
00:05:01.560 --> 00:05:08.560
Stay tuned for the next lesson where I will show you how to design database tables for calculated values.

