MySQL is the most popular open source database on the web. SQL, short for Structured Query Language and frequently pronounced “ess-que-el”, is a simple non procedural language that lets you store and retrieve data in a relational database. The spread of dynamic websites on the World Wide Web today is largely due to the possibility for their content to be handled through databases. Database management is a complicated process, which has been considerably rationalized by the SQL programming language. This “language” allows you to make queries about the information in your database – data selection, insertion, updating, and locating. A database is a collection if information that is organized to allow for easy retrieval. You can have a database of customer addresses, a financial database, even a database about your template collection.
Unlike other SQL, MySQL offers both a Community Edition (open source) and a Network Edition (licensed). MySQL Community Edition offers the advantages of being constantly updated and re-released to take advantage of the latest features. In addition, the MySQL open source version is completely free for those who are eligible for the general public license .
Right now i’m going to explain the type of encryption that you can save the data in the tables
lets start shall we
INT= Integer
This encryption of data saves only numbers that way if someone is trying to enter incorrect data it wont allow it
VARCHAR = Characters
This ecryption of data saves everything from numbers to symbols to letters its handy to use to store usernames, emails ect.
TEXT = Text
Text is similar to VARCHAR only this has no need to have a length of value to store data in it and the data stored in it is pure text only like Bio’s ect.
DATE = Dates Formats
This encryption saves the date of the day, you can store dates with this encryption
Now that i explained the basic encryptions of data that can be stored in the tables im going to start with the Length and Values
this part is simple you type in a number of how long the max size of the data that will be inserted in the rows
if you set the Length/Values to 10 and i want to insert a data with a length of 11 the database will Deny the info submitted
Next part that will be explained is the Default
Default means if you submit a query and that row is empty the Default will be Filled inside of it that way it wont stay empty
lets say i will submit a register form and i forgot to fill in my gender and the default on the database is Male when i submit the form
it will automatically fill in Male since the submission was empty he jumps to the default
You could either fill in a Default or leave it empty in MySQL empty is called Null
that means if a row is set as NULL its an empty row you can also set a Default as TIMESTAMP ill explain later what that does
You can also put attributes to your row or table but that is not necessary for this Tutorial
Now the next part is Setting a Row to NULL its different putting a Default to NULL that making the Row NULL
by that i mean if you set the table to NULL means if no data is submitted it will skip it and continue since you have set the row to NULL
that means it must not be filled that way it can stay empty and not nessera;y needed to fill in a NULL or something
INDEXES
there are 4 types of indexes
- PRIMARY
- UNIQUE
- INDEX
- FULLTEXT
For this tutorial you will only learn how to use the PRIMARY its one of the most important indexes and you will need him to make your table work properly.
A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself , or it can be an artificial field (one that has nothing to do with the actual record). A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.
Next thing is the AUTO INCREMENT
this can be used Once in a table, its mostly used to give rows on the table an Unique Identification cause it counts up from the last ID or however you want to call it a +1 every time a new row is Insert.
Since you probably want to start creating the table i will skip some not important details that will become important in the future but not for now other tutorials will explain it.
well lets skip and start creating a table well most MySQL panels you can standaard create a table by just clicking and filling info for example: PhpMyAdmin
but that doesn’t mean i wont explain the SQL code
since we want to create something we may want to start with the folowing
1 |
CREATE |
CREATE
but what do we want to create? yea.. table
1 |
CREATE TABLE |
CREATE TABLE
oh yea some other when you send command/SQL codes to the MySQL its mostly Capitalized
so now we started to create a table but now we need a name for the table
1 |
CREATE TABLE tablename() |
CREATE TABLE tablename()
you notice there is “()” after the name and its very simple why cause we are creating a table and what comes in the table
comes between those brackets or whatever you call it
well lets now start on creating our first Column with a name and the type of data we will save it
1 |
CREATE TABLE users( username varchar(length)) |
CREATE TABLE users( username varchar(length))
Yes we now have created a table with a column called username and we can go so and so
1 |
CREATE TABLE users( username varchar(25), password varchar(50), age int(2)) |
CREATE TABLE users( username varchar(25), password varchar(50), age int(2))
and you can go and keep doing this now lets set a Primary key will we
and the auto increment
well to make something in a table primary is easy lets make a table with 1 column and make that column primary shall we
1 |
CREATE TABLE users( username varchar(25), PRIMARY(username)) |
CREATE TABLE users( username varchar(25), PRIMARY(username))
thats how you do it its simple and its better if you make a primary till the end of the line now lets make a simple user table with an ID
1 |
CREATE TABLE users(id int(10) NOT NULL AUTO INCREMENT, username varchar(25), password varchar(50), PRIMARY(id)) |
CREATE TABLE users(id int(10) NOT NULL AUTO INCREMENT, username varchar(25), password varchar(50), PRIMARY(id))
as you can see we made ID PRIMARY and AUTO INCREMENT and we made ID to NOT NULL means no query may be saved without an ID
Now we know the basic of MySQL on the next Tutorial we will learn how to insert and get data of these tables















