Getting Started with SQL
What is SQL?
SQL Stands for Structured Query Language. It is used to interact with the database i.e. storing, Manipulating and retrieving the data. It is also called as SQUEAL i.e. Structured English Query language.
What is Database?
It is large collection of data organized in a structured manner and can be accessed in various ways. DBMS allows us users to interact with the database.
What is DBMS?
It is Database Management System. It is software system used to store, retrieve, run queries on data.
Types of DBMS?
Relational DBMS: It is used to store the data in rows and columns.
Ex: MySQL, Microsoft SQL Server.
Object Oriented DBMS: Data is in the form of objects supporting object oriented programming concept.
Ex: Object DB, Mongo Db.
Hierarchical DBMS: The data is organized in a tree like structure where data is stored in one-to-many relationship with each other.
Ex: IMS(IBM).
NoSQL DBMS: It is designed to handle large amount of data which is in unstructured or semi-structured form.
Ex: Mongo Db(stores data in JSON documents).
What are Constraints?
They are the rules and restriction applied on the type of data while creating a table.
Not Null: Cannot store null values.
Unique: All values in the column must be unique.
Primary Key: Must not contain null or duplicate values.
Foreign Key: Allows duplicate and null values and links data in one table to data in another table.
Check: Ensures that the value stored in a column meets a specific condition.
Default: Specifies a default value for a column when no value is provided by the user.
Below are some constraints applied to the data while creating a table:
Create database Constraints; Create table Student( //creating table. S_id int primary key, S_name varchar(15) not null, S_age int check(age>=18), S_institute varchar(15) default "XYZ" ); insert into Student values(1, "A", 21, "PQR"),(2, "B", 22),(3, "C", 21, null); //inserting data. select * //displays the details. from Student;
S_id | S_name | S_age | S_institute |
1 | A | 21 | PQR |
2 | B | 22 | XYZ |
3 | C | 21 | null |
Subscribe to my newsletter
Read articles from Swatipb directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Swatipb
Swatipb
The feeling of learning something new:-).