Session Prices

Feel free to negotiate depending on your situation.

Scheduling

Hit me up to work out a scheduled time and date.
[email protected]
213-995-7078 text or voice
Field Types

SQL means Structured Query Language. It's a language, just like any other programming language, except the language is optimized to query rows and columns of data.

Within this language are types. Types define what a column will be filled up with. For example, you can fill up a column with a number or text.

MySQL allows you to customize what values you put into your table. You have to be specific though. Here are just a few of the more popular types that you can add to your table.

Let's look at each one and their properties.

char - text field

defined like:
char(max length)
example definition:
char(64)

The char field stores text data. It can also store numbers, but MySQL doesn't understand that they're numbers. It only sees them as text. Typically you don't want to store numbers in this field if you need to do calculations. This is a great field if you'd like to store addresses, for example.

The char field takes up as much space as you defined in the max length of the field. For example, if you defined char(64), then each row that is added will always use 64 characters, whether or not you actually put 64 characters into it. If you use less space, it will fill up the remaining space with empty characters.

varchar - text field

defined like:
varchar(max length)
example definition:
varchar(1024)

The varchar field works exactly like a char field with one difference that takes place in the background: If you add only 32 characters to a varchar, it will only take up 32 characters in the database.

The tradeoff with char and varchar is varchar is a tiny bit slower when dealing with text strings than char. But, you get smaller storage. It's a tradeoff that you might be willing to make. In most designs, you won't need to worry about speed or space, unless you are building a system that is going to handle millions of records.

text - text field

defined like:
text
example definition:
text

What's the deal with text? Don't we already have char and varchar? Well, for even more flexibility in your text handling needs, you get text.

How do we specify how much we can put into a text field? We don't. The text field comes predefined to hold up to 64k of text. It works like a varchar in that if you only store 32 characters in it, it only puts 32 characters in the database. It just gives you more flexibility in defining text fields.

int - integer number field (no decimal numbers)

defined like:
int
example definition:
int

An int field has a range of -2,147,483,648 to 2,147,483,647. Essentially, you can't store a number that is higher than 2,147,483,647 or lower than -2,147,483,648. This is also called a signed integer. You also can not store any number that has a decimal in it, aka fractional numbers, or floating point numbers. For example, you can store 10, but you can not store 10.1

What if you don't care about numbers below zero, but you'd like to store numbers higher than 2,147,483,647? The answer is that you would prefix unsigned to int, like: unsigned int. Your field would then allow you to use an integer number up to 4,294,967,295

float - floating point number field (can include decimal numbers)

defined like:
float
example definition:
float

The float field allows you to store floating point numbers, such as 10.1 or 0.99 or 4.1999999. The float field works similarly to an int field, except that you can store numbers with decimals. The range of what you can store is hard to define with floats and depends on how many decimal digits you store.

decimal - floating point number field (can include decimal numbers)

defined like:
decimal(m,d)
example definition:
decimal(6,2)

The decimal field allows you to store decimal numbers, such as 10.1 or 0.99 or 4.1999999. The decimal field works similarly to a float field. The difference between decimals and floats is that you get to define exactly how big the whole number is and how big the fractional number is.

The way you define a decimal number works like the following decimal(6,2). The first number in the definition is how many numbers you can store in the field. The second number moves a certain amount of those numbers into the fractional number area, so to speak. So, the definition above would allow a maximum number of 9999.99.

The decimal field is great when you want to store money or other specific decimal number types.

date or datetime - Stores a date or a date and a time

defined like:
date
defined like:
datetime
example definition:
datetime
example definition:
date

The datetime field allows you to store dates and times or dates if you are using the date type.

All MySQL dates are specified like the following: 2020-02-02 14:02:02. Basically, year-month-day hour:minute:second.

More about dates, times, and timestamps are covered later.

There are a lot more field types that MySQL supports, and we'll be covering some of the more esoteric field types in the future.