Placeholder Image

Subtitles section Play video

  • creating these classes requires equipment and service.

  • Is that cost money?

  • If you appreciate this education, please think about going to Eli the computer guy dot com and offering a one time or monthly recurring donation.

  • Welcome back.

  • So as you know, I'm Eli to Computer Guy.

  • And today I just want to do a small class talking about data types for values that you were going to be putting into your my sequel database.

  • So this is one of those things.

  • It's very important from a high level point of view.

  • So if you're going to going out there, you're gonna be creating a front end you're going to.

  • Using my sequel in a production environment is very important.

  • Understand why data types are significant and is also one of the things that can really screw up new people.

  • So there's kind of one of those it's important all the way around.

  • So what are we talking about when we're talking about data types for the values that you're going be in putting into your my sequel database?

  • Basically, all we're asking here is what type of information are you going to be in putting into your my sequel?

  • database as a value.

  • So is that a name?

  • Isn't it a?

  • Is it a price Isn't a file.

  • You can actually put files.

  • Something called a blob data type into my secret database.

  • Is it a date?

  • Is it any number of different types of data types that could be a value in your database?

  • Now, why is it important to designate what something is?

  • Why is that important?

  • To designate that something is text or something is an end or something is a float or a decimal or a blob so on and so forth?

  • Well, one of the problems you run into in the real world when you put a database into a production environment is at some point you're going to have a front encoder that does something.

  • Asa nine Lee stupid.

  • Right there sitting there.

  • They've been working 100 hours that week.

  • They're trying to get a get a front end and deployed some kind of submission form.

  • So basically, somebody's going to submit their names, always gonna submit their their age, their T shirt size, whatever else, and that's goingto populate your database.

  • Well, the problem is, is if they're not thinking about things right and they do something stupid.

  • Basically, what they could dio is they could.

  • They could have the name of field trying to input data into the age column in your database.

  • Or they could try to put the age field going into the name column in your database.

  • And that can cause a lot of issues.

  • Now, if it's if it's a big problem, right?

  • So if you get 1000 new records and all of that information is screwed up, that might actually not be the worst thing that could happen to you.

  • The worst thing that could happen to you is if only one or two values are able to be inputted into the improper place within a database that can cause you a massive, massive issue.

  • Right, So basically, imagine if you're going to do something like taking an average.

  • So let's say you want to take the average of all the invoices, so you have the total for invoices, all the invoices your company is doing.

  • So you have thousands of thousands and thousands of these invoices, and you just want to see what the average invoice value iss, right?

  • So basically you will create a little script.

  • It'll go in, it will grab, grab all the different values.

  • It will add them all up and then we'll divide them.

  • Well, one of problems you can run into is you know, basically as that script is going through when it's saying OK, this value is 100 this value is 200 this value is 300.

  • And this value is Bob and his values.

  • 1000.

  • This value is 4000.

  • This value is 10 right?

  • One of the issues you can run into is that basically, when that script is going through to do the math that it actually does try to add Bob right one plus Bob equals what?

  • Right.

  • This is one of those times where you actually hope in a real production environment, you actually hope it fails.

  • You hope it fails.

  • Because if it fails, then you know that there is a problem.

  • And then you got to go in there and try to figure out what the hell is going off.

  • One of things that happens in the real world sometimes is two plus bob equals something right on again, especially when you start doing a large scale math.

  • That could be a real issue if you If you're adding up 10,000 different values and one of those values is Bob, it may skew the output that you're getting the end result that you're getting.

  • But it may not skew it to such a degree that the human eye recognizes that it's screwed up.

  • You know, he said, there you look at a go.

  • I I thought the value of the invoices would be a little bit higher than that.

  • But okay, I guess if if the computer tells me that this is what the output is, I guess I guess that's what we're doing.

  • We're gonna have to go out there and start flogging some sales people.

  • Right?

  • So the important thing with data types is, what you can do is you can say this field in the database will only accept this type of data.

  • If you try to put Bob into an ent field, that only allows that a type of end So integer is a whole number one.

  • The 10 negative 10 100 1000 right?

  • So you try to put Bob into a field that only allows for ends that will then fail out, so that could be a useful thing.

  • One of the problems, though, and this is the problem for new people, is if you don't understand the different data types, you can also run into some issues when you're trying to put data into your database.

  • So again an ant is a whole number is an integer 1 10 1000 and 20 10,000 and 20 negative 10,000.

  • A whole number is an end, a float or a decimal.

  • That is a number that has the decimal point to it.

  • So 10.1200 point 55 that type of thing that would either be a float or decimal.

  • So one of the problems you could get into again when you're new to coding for my sequel or any of these databases is, let's say you're trying to create it creates some kind of invoicing system, and so you have the price.

  • And so it's, you know, 100 and $200.25 or $10.5 and they're doing taxes and all that kind of stuff.

  • One of problems you can run into is If when the data goes into the database, it strips off the decimal point or you have some other kind of issue, then you can run into some issues there.

  • And you think, Well, wait a minute.

  • I don't understand because it's an end.

  • It's a number.

  • It's a number value type.

  • Therefore, I should be able to do this.

  • But again, there's different number value types.

  • There's intake, yours, there's floats, there's decimals.

  • There's that kind of thing.

  • So basically, all we're talking about when we're talking about the data types here is we're just talking about what type of data is able be inputted as a value into a particular column within a database.

  • Why this is important again for the high level professionals is because you don't you don't want to find that you don't want to find out what you believe Bob equals.

  • Doesn't matter.

  • You don't let that happen on why this could be an issue for new peoples again.

  • You go in your design, your database, you're feeling all good on.

  • Then you find out that there was a reason whenever you're whenever you have the code and is trying to put that into the database that it fails out.

  • And the reason it may be failing out of that mate, Maybe a reason that's causing problems is because you're putting in a different type of data type.

  • Then what you've assigned for that particular column.

  • So that's what we're talking about data types here and why this is important.

  • So for this class, I'm not going to go through all of the different data types.

  • There were actually a shocking number of data types out there.

  • And again, if you start dealing with databases to a significant degree, you will learn and you will memorize all of these data types.

  • And you will figure out which one is the best to use in any particular situation.

  • But for special a lot of new people.

  • Or if you're just trying to learn, we don't We don't need to go that far in the wart woods.

  • We don't have to go that far in the woods for you to get the point in the real world when you were learning this stuff.

  • Basically, what you wanna dio is you want to figure out okay, I'm gonna have a form, and this form is going be collecting this type of data and you Okay, what data type is that?

  • And you do do do a Google search.

  • You okay that data types that that data types, that that tops that.

  • And then you go you're my secret database and you design your my single database.

  • And again, that's how people do it in the real world.

  • So with that, let's go to the computer so I can show you I can show you one page.

  • That's kind of a feat.

  • She gives you some explanation of these different data types, and then we'll go to the actual my sequel reference where it gets much Maur End of the weeds and maybe more important for you again, if you're if you're actually go out and start designing things that will be going into a production environment.

  • So as with anything in coding or really almost anything that you do in the technology world, if you're trying to figure something out, one of the best things to Dio is just simply plug it into Google and see what shows up.

  • When you're dealing with any kind of Cody and stuff, you're dealing with any kind of like database type information.

  • One.

  • The important thing is to understand is people learn differently depending on who's who's writing the information and how that information is presented.

  • So you may be a more visual learner where only you need is something like a spread sheep.

  • You may need something explain to you mawr in depth.

  • And so it is important.

  • Understand that as you're learning these things, just going to Google and finding particular websites that explain things to you.

  • The best is really the easiest way to go.

  • So again, we're talking about data types that types or specific things.

  • But how you could get that into your head might be a little different for everybody.

  • So you just plug in my sequel data types here.

  • I found this one little my sequel tutorial.

  • This basically looked like a decent little cheat sheet to give you an idea of the different data types, and there are a lot of that types, so you have char bar chart, tiny text, text, blob, medium text, medium blob, long text, long bluff, tiny and small, and medium it and big and float double decimal date, date, time, time stamp time and new set bullion, which isn't really bully, and it's actually a tiny end, but this gives you an idea of just some.

  • Is this so literally?

  • This is some.

  • This is a few.

  • This is a couple off the different data types that are available for you on.

  • So basically what the data types, you have the type of data you can put in.

  • So basically, is it a total Alfa in America?

  • Can you put in numbers and letters?

  • So for char bar char is that only numbers?

  • So basically again, with its ends or floats, you can only put in numbers.

  • Is that whole numbers, or is it decimal point numbers so on into tiny into small and medium and those of the whole numbers?

  • So 10.

  • A 1,000,010,000 of their ends where as a float or a decimal, would be 10 not 99 or $11.25 or 1,000,026 250.33 type of thing if you go and you take a look at a speck thing, what this is telling you is basically how many characters can you insert into the values for his char going 0 to 255 characters for a tiny text, the same for a small, and you can go from anywhere from a negative 1 28 to 1 27 on.

  • Basically, this just gives you an idea of how much information that you can put in.

  • So for a lot of values that you're gonna be starting out with for for your particular projects, thes these numbers probably won't matter a lot.

  • But as you start putting in a larger individual pieces of data into a single value, this may may cause you some issues.

  • Here we come down, we can take a look again.

  • My sequel, numeric data types so tiny and small and medium and the end of the big into the decimal that float the double bits.

  • Eso those were some different numeric types.

  • We come down here to the strings, so strings or things like names, names, sentences, subject lines, messages.

  • Whatever else jar of arch are by bin by binary tiny blob.

  • So these are kind of cool.

  • The blobs.

  • I like the blobs eso I do a daily talk show or slightly daily talk show called The Daily Blob, or, I guess, kind of ramble about random things that I want to talk about and and where the name for the Daily Blob came from is the blob data types.

  • The blob data type means you can literally put almost anything you want into the database.

  • Not only did he put text or numbers or strings or whatever, but you could put MP three pot files.

  • You could put PdF files.

  • You could put movie files or whatever else.

  • You can actually put files directly into a database, though with the blobs.

  • This is one of those things where again, what is technically possible and what is an acid only stupid idea can be the same thing.

  • What people have found out over the years is generally not a good idea to put files directly into a database.

  • Because remember, with the database, you have to think about things like how you're gonna back up the database replication strategy.