Using standard query language (SQL) we can create database, table and other tasks can also be achieved. But the bitter part, most of the new learners are not aware the difference between database and table. Before understanding the difference between database and table, lets discuss in brief why database requirement came.
Earlier days data were stored inside files which were not easy to retrieve back. And the process was time consuming. As internet usage increased, it became extreme hard to store large number of data and retrieve back if required. Thats why database gradually came into existence.
As the name says, database is the base for holding all data and table is the container for the data. To better understand this lets take one example.
Lets take another simple example:
You must have known how a kitchen room looks like.
Inside the kitchen room, there is Stove for cooking, there is microwave oven and there are cupboards.
What are there in the cupboard?
Various jars are present.
One jar contains masala, another jar contains tea, another jar contains coffee, another jar contains sugar, another jar contains salt, another jar contains oil etc.
More or less most of the cupboards in the kitchen room contains such jars. Right?
So here the cupboard is database and each jar is a table.
Therefore in simple language we can say database is holder for tables and each table contains specific information.
Now you must have clear understanding of the difference between database and table.
Assume ‘ABC’ school decided to create a website in which students can access their exam results online. In this school, there are only five classes are present (6th class, 7th class, 8th class,9th class, 10th class)
Each class is having five subjects in their syllabus : Math, History, English, Social Study, Geography
There ABC school must have to create database to hold exam results of students. This database name could be “ABC EXAM RESULTS” (in database names no spaces allowed, but ignore for understanding purpose)
ABC EXAM RESULTS database is going to contain 6th class results, 7th class results, 8th class results, 9th class results and 10th class results.
Each results are tables.
Inside database, 6th class result table, 7th class result table, 8th class result table, 9th class result table, 10th class result table needed to be created. These table going to contain results of respective classes.
NOTE: Without a database no table created.
When you work on any project, first you need to create database and then you need to create tables for the database.
Just imagine, Railway projects, banking sectors, are having huge database. Those databases contain lots of tables.
To access a value from a table, you must be aware of the database name.
Following is a pictorial representation of five students of class 8th secured marks in Math Subject in a tabular format.
How many rows and columns contain this table?
Six rows and four columns.
Here first row contains column names and rest rows contain respective values. Each value is known as data.
Roll no 1 whose name is John, he has secured 90 marks in Math.
Roll no 2 whose name is Rita, she has secured 95 marks in Math.
Roll no 3, whose name is Sam, he has secured 84 marks in Math.
Roll no 4, whose name is Jack, he has secured 72 marks in Math.
Roll no 5, whose name is Pom, he has secured 99 marks in Math.
Here, roll no values, student name values, subject values, marks values are referred as data.
In sql, a requirement might come to find the roll no and name of the student of 8th class who has secured the maximum marks in Math.
In such scenario, we are required to find data of roll no, and data of name of the student who has secured the maximum marks in Math.
data value would be: 5, Pom
NOTE: If some one asked you how many rows, the table contains?
Your answer must be 6. But in SQL, we exclude the row from count which contains column names. There fore the answer would be 5. The table contains 5 rows.
More specifically, in SQL world, we refer each row as record. Because we are recording data into the table.