MySQL | Basics

MySQL | Basics

MySQL is a Relational Database Management System (RDMS).
MySQL stores data in row and column format.
MySQL stores different types of data eg. it stores integer, string, boolean, date, time, decimal, BLOB(binary large object).
To create database,


create database myDatabase; 
use myDatabase;

This statement will create a new database named myDatabase will be current database in use.

This statement will also create system tables like information_schema, root, user and so on.
This table contains the configuration and management of the user table.

Point to rememeber:- SQL is not case sensitive and hence MySQL is not case sensitive.

Question:- How do you create a table in my SQL?
Answer:-


Create table Nutan_Vidyamandir (
Division int(5)
Date_created date default Now()
Date_modified date default Now()
Annual fees int(200) 
ID int(10)
Primary key ID auto_increment)
engine=innoDB


Explanation of the above code:

The first line defines number of divisions for a particular class i.e., grade and if type is an integer For example if Swara Joglekar is in 2nd grade in E Division the table for 2nd Standard students for Swar Joglekar the value of division will be 5.
The moment when the arow was created for the first time in return by the now function which is builtin function my experience.
The last time a row was updated will be automatically stored in the date_updateded column.
Suppose Swara PAYS rs.100 000 for 2nd grade, then the table for 2nd grade will contain a column named annual_fee as 1,000/- in Swara's row.
Primary Key:-
A primary key is a unique integer for every row in database table. Suppose if there are 10 students in one division each row will have unique ID is called primary fees. The primary fees is automatically incremented by one whenever new student take admission in the School eg if the primary key of Swara is 30 and new student named Arya take admission in the same division her primary key will be 31 (30+1) Now suppose Manish has ID 10, and he leaves the School, the new person will take admission will have ID 11 and not 10 becasue 10 is already used even if it is freed.

Comments

Popular posts from this blog

Parallel Database design, query processing

Laravel | PHP | Basics | Part 2

Apache Hadoop | Running MapReduce Jobs