What is SQL, Data, Database, DBMS, RDBMS?


What is SQL?

SQL stands for Structured English Query language. It can be defined as a language used for relationship databases to get query or data out of the databases.

What is Data?

Data is collection of facts which includes words, numbers or pictures.

What is Database?

In simple language Database is a program that stores data. It is a repository of data. It provides the functionality for adding, modifying and querying that data. There are different kinds of databases for different requirements.

What is SQL?
What is Database?

Some types of databases are relational model, hierarchical model and entity relationship data model. Data stored in a tabular form is a relational database. It has rows and columns but not all databases have tabular format.

What is Database Management System (DBMS)?

A set of software tools for the data in the database is called Database Management System.

What is Relationship Database Management System (RDBMS)?

A set of software tools that can control the data access, organization and storage is called as Relationship Database Management System (RDBMS).

What is database service instance?

Database services are logical abstractions for managing workload in a database. An instance of the cloud database operates as a service that handles all application requests to work with the data in any of the databases managed by that instances.

Now let us understand the terms Data Definition Language Statement and Data Manipulation Language Statement.

Data Definition Language Statement defines, changes or drops the data while Data Manipulation Language Statement reads and modifies the data.

Now let us learn some basics SQL commands and functions:

How to create a table?

The basic syntax is:

create table <table-name>
(
Column-1 datatype,
Column-2 datatype,
....
....
);

Some inbuilt terms which we should know are:
char - String variable of fixed length
varchar - String variable of variable length
no null - indicates that the entry to the database can have no null values
integer - variable type integer
primary key - It is set so that we get no duplicates in the rows.

So lets start creating a table:

We create a table student having id_no, firstname, lastname and grade.

create table student
(
id_no integer primary key not null,
firstname varchar(20) no null,
lastname varchar(20) no null,
grade char(1)
)
;

Now that table is created we can insert the data into the table using insert command as follows.

The basic syntax is:

insert into <table-name>
<([column-name],...])
values
([value],....])

The values should be added in the same order as the column's have be entered.

insert into student
(id_no, firstname, lastname, grade)
values
(1, 'Raj', 'Kumar', 'A'),
(2, 'Sunil', 'Yadav', 'A')
(3, 'Rohit', 'Pal', 'B')

Now we get a student database with the data of three students in the form of three rows. We can add as many possible rows to the table as follows:

insert into student
values
(4, 'Kapil', 'Sharma', 'A'),
(5, 'Suresh', 'Dev', 'B')
and so on

After learning how to make a table in SQL and how to insert values in it, let us now see how to drop a table.

drop table <table-name>

This simply drops the table, that is it deletes the table. Be sure when drooping a table, as table once dropped we can not recover it.

How to update a table?

Syntax:

update <table_name>
set [[column name]=[value]]
where[condition]

How to delete something from table?

Syntax:

delete from <table-name>
where [condition]

How to select something from tables?

select * from <table-name>  --- This will select all the rows of the table

select <column1>, <column2>  from <table-name> -- Select the columns from where you want the values.

Then we have the where clause which is very useful for querying the data from the table.

> It restricts the result.
> It always requires a predicate.
> It evaluates to : True, False or unknown.

Example:

select firstname, lastname from student
where grade = 'A'

we get output in the tabular form as follows:

Raj Kumar
Sunil Yadav
Kapil Sharma

These are only some basic's of SQL. Do come back for updated contents.

Comments