How to Create Database and Table in MySQLNawaraj Shah
Hello guys, In this post I will guide you to create a Database and Table in MySQL. But before we get started, first we have to know what are database and table?
A Database is an organized collection of data, generally stored and accessed electronically from a computer system. And we divide our database into tables to organize our data.
A Table contain rows and columns. In each column we define a data type and in each row we store individual record.
Now to create a database first you need MySQL. And you can get MySQL through XAMPP software but you don’t have installed XAMPP and don’t know how to get, then watch this video. After that, start Apache and MySQL.
Then go to in a URL section of browser, type http://localhost/phpmyadmin Then you will get a page like this.
There are two ways to create a database. Either you can create by using SQL coding Or you can create without coding just manually. Here we learn to create a database manually.
Creating a Database
On the top left portion of phpMyAdmin, you can see a NEW button.
Then give a name to your database and click Create.
Creating a Table
After that, give a name to your table and specify, how many column you want to create then press Go. Now we need to specify some property for our column which include name of the column, data type for that column, length of string, index and many more.
In the Name section, define name for each column. In Type section, define a dataType for each column. If you set Type of column as string/text then set a Length. In a database table, we need to set one column as a primary key.
Primary Key are those column which contain only a unique record. So that we can easily work on each record of that table. Now to make a primary key, make a one column Name as id , Type as INT and Index as PRIMARY.
After you define column name and its property then just save it.
And that’s it, you have just created a database and table. Now you can use it on your application.
Now, if you want to learn How to connect this database to your HTML form then read this.
Or you can also watch this video.