Posts

Constraints in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Constraints in SQL". We have learn CRUD operations so far, now its time to advance our skills. We will again create a table with some properties and make our database table more reliable and effective. For making our database table more reliable and effective we are going to add some "Constraints" in our table.  So in this blog we are going to talk about What is constraints ? Types Of Constraint. Create a table with constraints. Let's start with 1) What is Constraint? Constraints are nothing but rules which a data row must satisfy to get inserted in database. For example: When a person wants to take flight he/she have to go through many checks like security, passport, boarding pass, etc. these checks are there to ensure only valid person can enter flight and flight will...

Update, Delete and Truncate Commands

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Updating and deleting data". We learn about "Inserting and Retrieving Data" in  this blog . Now its time to learn updating and deleting our mistakes. Yes with the help of the UPDATE and DELETE  statements  you can actually update and delete wrong entries in your database respectively. So in this blog we are going too talk about  UPDATE statement DELETE  statement TRUNCATE command Let's start with 1) UPDATE statement : UPDATE statement is used to update a specific record or a bunch of records which exists in your database table. If you made a mistake while inserting data in your database then UPDATE statement is the loophole through which you can correct it. Let's see a example: If you can see in our table I have made a mistake that SALARY  of "Sales Per...

More clauses in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "More clauses in SQL". We learn about "WHERE" clause in this blog . Now its time to learn more clause which are going to help us to be more specific about retrieving data from Database and eventually its gonna make us more and more efficient in handling data in Database. So, In this blog we are going to talk about GROUP BY clause HAVING clause ORDER BY clause Now, let's talk about 1) GROUP BY clause This clause is often used with Aggregate Functions (which we have learnt in previous blog ) so that we can group our result with a particular column. I know it sound little confusing but we will solve this confusion with the help of example. Let's consider a scenario where I told you to count number of people working in each department with our existing Employee table. So then you might write a query like this: select count(*) from Employee where Department='IT' Then you will keep rep...

Aggregate Functions and like operators in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Aggregate Functions and like operators in SQL". In previous blog we have seen inserting and retrieving data from database, today we will see more combinations in which we can retrieve data and we will also see some of the functions which help us in performing some calculations. In this blog we will talk about : Aggregate functions LIKE operator 1) Aggregate Functions: Aggregate functions performs calculations on a set of values. Aggregate functions are also known as singled valued function because every time you use them you will get a single valued result. SQL has 5 aggregate functions : COUNT() MIN() MAX() AVG() SUM() One important thing is aggregate functions ignores null values ( when you don't enter value of a column while inserting a record then that column has null value that actually means "no value") except when it comes to count() aggregate function it considers null value. COUN...

Inserting and Retriving Data from Database

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Inserting and retrieving data from database" in database. We have created a simple Employee table in our previous blog (  https://learntocodewithmustafapinjari.blogspot.com/2020/07/basics-of-sql.html  ). Now its time to add some data in that table and then we will see how we can retrieve that data. In this blog we will talk about : Inserting Data Retrieving Data Operators in SQL 1) Inserting Data : There are 2 syntax available in SQL for inserting data. Both are simple. Let's see them one by one Syntax 1 : insert into table_name values (value_1, value_2,........,value_n) Example : insert into Employee values(1, 'John', 'Doe', 'Sales',50000,'Sales Manager') In this syntax you have to make sure that you maintain the sequence of  values as per the sequence of column in the table. If you  miss a value or you add more values than number of column then you will get an error....

Understanding Queries and Creating Database

Hello, and welcome to the blog. In this blog we are going to talk about "Queries" in database. As we discussed in my previous blog (  https://learntocodewithmustafapinjari.blogspot.com/2020/07/basics-of-sql.html ) that SQL is used for performing different operations on database. But how SQL do it? It is actually actually done by "Queries". Don't worry here "Query" doesn't meant doubt. In this blog we will talk about : What is a Query? Types of Query. Creating our database with the help of query. Let's start with 1) What is Query? Query is nothing but a statement or instruction to communicate with manipulate database or to manipulate database. By using queries you can create a database, insert values in table, update those values, delete rows and many more operations can be performed. 2) Types of Query. There are 5 types of query: DDL : Data Definition Language. DML : Data Manipulation Language. DCL : Data Control Language. TCL : Transaction Con...

Understanding different data types in SQL and Creating table

Image
Hello, and welcome to the blog. In this blog we are going to talk about different data types available in the SQL and we are going to create our first table in which we are going to store data. In our previous blog(  https://learntocodewithmustafapinjari.blogspot.com/2020/07/understanding-queries-and-creating.html  ) we learn how to create database and we created a database named as "EmployeeManagementSystem". Now its time to create some tables in our database so that we can store our data. So in this blog we are going talk about: Understanding data types Different data types in SQL Creating a database table Adding Column to existing table Lets' start with : 1) Understanding Data Type: It is very important to understand "Data types" before creating a database table as your table is going to represent a data for a specific Entity. "Entity is thing with distinct and independent existence" like a Person, Car, Shop, Institute, Animal etc. Every entity do h...