WEBVTT

1
00:00:00.000 --> 00:00:06.800
Hello, welcome to KnowledgeCity's course on Microsoft Access 2021, Intermediate.

2
00:00:06.800 --> 00:00:12.320
My name is John Veron and in these lessons you will learn about field properties.

3
00:00:12.320 --> 00:00:15.920
In this lesson I will show you about choosing the correct data type.

4
00:00:17.040 --> 00:00:21.280
As we've seen before each field has a list of data types to choose from.

5
00:00:21.920 --> 00:00:27.120
Choosing the correct one is integral to having a good database design and can also make

6
00:00:27.120 --> 00:00:32.320
a big difference in how easy your application is to use and how much work it takes to maintain.

7
00:00:33.120 --> 00:00:37.520
I'm going to go through the most important data types and explain what types of data they're

8
00:00:37.520 --> 00:00:42.880
best used for and I'll also discuss some information commonly stored in databases and talk

9
00:00:42.880 --> 00:00:51.740
about what data type is best used to store them. Let me just create a table here we can use as a

10
00:00:51.740 --> 00:01:03.890
reference. Let's start with the string data type. Which in Microsoft Access is called either

11
00:01:03.890 --> 00:01:12.050
short text or long text. Short text can hold a maximum of 255 characters while long text can hold

12
00:01:12.050 --> 00:01:22.290
up to 65,536. In general always use short text unless you're sure you need more than 255 characters

13
00:01:22.290 --> 00:01:28.770
because a long text data type is handled differently internal to access which can lead to slower

14
00:01:28.770 --> 00:01:35.890
performance or can require some special considerations. Text is the most general data type meaning

15
00:01:35.890 --> 00:01:41.810
you can technically store anything in there numbers dates currency or whatever else you can think of.

16
00:01:42.690 --> 00:01:48.770
The problem is that no matter what you store in it access won't see it as anything other than text.

17
00:01:48.770 --> 00:01:53.330
This means if you store numbers in here you won't be able to compare them like normal numbers

18
00:01:53.410 --> 00:01:58.690
or perform math on them. If you store dates you won't be able to check which dates come before

19
00:01:58.690 --> 00:02:04.770
others so always use one of the other more specific data types whenever possible and only use a

20
00:02:04.770 --> 00:02:13.570
text type when nothing else will work. However some pieces of data can look like a different data type

21
00:02:13.570 --> 00:02:21.010
but still fit best as text. A good example could be zip code. On the surface a zip code looks just like

22
00:02:21.010 --> 00:02:27.410
a number so you might be tempted to use a number data type. However zip codes can contain a hyphen

23
00:02:27.410 --> 00:02:33.170
and you won't be able to put that in for a number data type. Therefore it's often best to store

24
00:02:33.170 --> 00:02:39.570
zip codes as text. Besides you usually won't have to perform math or comparisons on zip codes anyway.

25
00:02:42.130 --> 00:02:48.130
The number data type is probably the next most commonly used data type. This is best used for things

26
00:02:48.130 --> 00:02:53.170
that are just a number with no other parts to them. This one behaves a little differently from the

27
00:02:53.170 --> 00:03:00.850
other data types because it really depends on the field size property. That's this one right here.

28
00:03:01.890 --> 00:03:07.170
Changing the field size will essentially make this behave like a different data type. The size is

29
00:03:07.170 --> 00:03:12.690
bite, integer and long integer will all treat the number as an integer meaning they are round

30
00:03:12.930 --> 00:03:19.410
numbers without a decimal portion. The difference between them is the maximum number they can store

31
00:03:19.410 --> 00:03:26.050
for most purposes integers a good default size. Single double and decimal are all numbers that can

32
00:03:26.050 --> 00:03:31.490
store fractional decimal portions. Similar to the integers the difference between these is the

33
00:03:31.490 --> 00:03:38.290
maximum number and precision that they can store. These could be used to store currency but there

34
00:03:38.290 --> 00:03:47.500
is actually a data type that will work better for that. The currency data type is designed for

35
00:03:47.500 --> 00:03:53.340
storing money. It takes less storage space than the decimal data types allowing only up to four

36
00:03:53.340 --> 00:03:59.420
decimal places but that is more than enough for currency. It will also automatically add the currency

37
00:03:59.420 --> 00:04:08.880
symbol based on your locale and your operating system. Date time is exactly what it sounds like

38
00:04:08.960 --> 00:04:14.480
and is made for storing dates, times or a combination of both. Dates and times stored in this data

39
00:04:14.480 --> 00:04:19.760
type can be compared and sorted which you would be unable to do if they were stored as text.

40
00:04:20.560 --> 00:04:26.960
Yes, no is a special data type that can only have two possible values yes and no or sometimes

41
00:04:26.960 --> 00:04:33.520
referred to as true and false or one and zero. Other databases may call this type something like

42
00:04:33.520 --> 00:04:40.640
bull, boolean or bit. They are all the same thing. This data type is great for storing any sort of

43
00:04:40.640 --> 00:04:46.480
flag which is a toggle that can only have two possible values. Things such as whether a record is

44
00:04:46.480 --> 00:04:52.800
active or not. Note that if you combine this data type with making it not required then the

45
00:04:52.800 --> 00:05:00.160
column will allow three possible values yes no and no. So if you need a flag with three possible

46
00:05:00.160 --> 00:05:08.400
states this is how you would do it. Hyperlink is a data type which is just a special case of the text

47
00:05:08.400 --> 00:05:14.160
data type. You could put hyperlinks into either type but if you use hyperlink then access will

48
00:05:14.160 --> 00:05:20.080
automatically let you click on the link to open it. So you can choose text or hyperlink depending on

49
00:05:20.080 --> 00:05:28.640
whether you want users to be able to click the link or not. Attachment and OLE object are special

50
00:05:28.640 --> 00:05:34.000
data types that you won't normally need but they are designed to store entire other files or

51
00:05:34.000 --> 00:05:40.880
application objects directly in your database. In general unless you have a specific need to do this

52
00:05:40.880 --> 00:05:47.840
it is best to avoid doing so. Hopefully this gives you a good understanding of the main data types

53
00:05:47.840 --> 00:05:54.320
and to best use them effectively. Thanks for watching. Stay tuned for the next lesson where I will

54
00:05:54.320 --> 00:06:04.320
show you field formats.

