7 hours 36 minutes
I welcome back to Module three sequel programming.
This is Lesson one sequel statements,
and we're currently in sub lesson, 1.7 data types,
and in front of us, we have a chart from my sequel tutorial dot org's I will Have an Equivalent available for download. But this comes from the My sequel Documentation. So it'll be the same now. What is a data type? Well, that types exist in most, if not all, programming languages. It's a way for you to indicate what type of data
that specific variable is and how you expect the engine or programming like language to work with that data. For example, when we tell a programming language that this is an imager,
that's different, and we expect different operations to work. Then when we say this is a string or a character or text,
when we add text together, that's very different than adding images together and the outcomes of those air different. And when we tell
the program Leijer what Dad attacked to use, we're telling it how much memory space to use for that data type as well.
when we indicate an imager,
we're told that we can use a negative number that could be a small. Is this highlighted number
and a positive number that could be as big as this highlighted number
put that into a binary conversion. And these come from binary numbers, which are
come from the fact that appears on Lee. Think in ones and zeros. Right now we'll see that we'll get this number back,
which is 31 bits
with a 32nd. But that represents that it's positive or native. For example, the positive variant has zero here. The negative Arent has a one here
now, just to kind of very simply state how big numbers work. And we have a two bit number. We can represent four numbers. We have a three bit number, could represent seven numbers and so on and so forth. That's why when we get to this size, we can represent a very large number, which is way too many numbers to really plot out all of them.
So the fact that has is that we know that this is a 32 bit number we know when we tell my sequel. Hey, this column type is imager. My sequel saying, Okay, I'm gonna use 32 bits of space for every record you add for this number. When we had a record and we save data to that column with an energy type,
we're using 32 bits of space,
whether we put in the largest number or we put in a five. The same thing with big imager is that whether we put in a five or the largest number it supports were using that amount of space,
which I believe this is 64 bit, but I'm not completely sure I'd have to look it up. The point is, it takes the big end takes up a lot more space than the manager. The reason we would use imager instead of big editor
is because imager takes up less space than big manager, so this may not matter as much in a smaller application. But as your application grows to thousands, millions or billions of records, amount of potential wasted space from a port datacom decision grows as well.
For example, if you were using a
ZIP code as a column and you made it a big ends, and we know that zip codes do not get to this size and that we would have been fined using a regular imager type. Then we're wasting a lot of space because every time you save a record, it uses the amount of space that this largest or smallest number will could potentially take up.
The same thing occurs with Char's bar charts and tax. If you use more than what you need, you end up wasting space, and that waste gets worse and worse as you go along.
For example, if you're saving the state code and you know state codes are only two characters long, you could put chart, too.
But if you put Char 2 55
then the database engine is saving on others, using enough memory space to support up to 255 characters, whether you use it or not. So again, it ends up wasting spiff. So as you develop your programming skills, you'll want to take in consideration what data type you're using and what size of data you need.
So that brings this lesson to a close. We went over my single data types, why the airport and and why you would use manager instead of big manager or flow instead of double. It comes down to how much space you think you're going to need for that data type. If you are interested in being efficient and you should be, you should try to use what you're going to
to need because they will help your applications scale up without eating so much space.
Then you should be aware of what the data type is, how much space it permits and what the maximum values for that data type is.
Anyways, that brings this lesson too close. I hope you enjoyed it. And I hope to see in the next one. Thank you.