Friday, 22 April 2016

Database with MySQL

MySQL is an open-source relational database management system(RDBMS). Before proceeding further one should have the knowledge of what exactly database is?

Database is a application that stores collection of data. Relational database management system is used to store and manage huge volume of data, all data is stored into different tables and relations are established using primary keys or other keys known as foreign keys. Primary key is unique, and can not occur twice in one table and foreign key is the linking pin between two tables.
To use MySQL database, it is essential to become comfortable with mysql command  line.  So here are the basic commands which I went through to start with mysql database.
  • SHOW DATABASE - Used to view all available database.
  • USE <database name> - To work with specified database.
  • CREATE DATABASE <name> -  To create a new database.
  • DROP DATABASE <name> - To delete a database.
  • CREATE TABLE <name> - To create table.
  • SELECT command is used to view rows or column from a table.
  • WHERE command used to view only records that matches a specific condition, it can be with "greater than>", "less than<","not equal to!=" oe "equal to=". It can be used with OR, AND, NOT to combine multiple condition.
  • CONCAT function is used to combine values from multiple columns and display it. 
  • COUNT is used to display the total number of records in a table.
  • GROUP BY command is used to group records on certain conditions. There many more commands which we can understand more clearly only by using them.
So to see how these commands work I connected to MySQL server using MySQL client using mysql command, as it was already installed in system. After logging in successfully I created a new database for me named test, which I decided will contain different tables having student details, test detail, classes details,score details etc. Once my database was created I created various table inside it defining its parameters. Then I inserted the values to different tables according to the parameter defined by using INSERT command.
After doing this much of work I started playing with the tables by altering their name, by adding something new to them, by adding new column to them , by merging two columns and lots more things. It was a fun to extract different information by using various commands from different tables, and this is how I learned basics of MySQL.

No comments:

Post a Comment