Posts

Normalization

Hello, and welcome to the blog. Today we are going to talk about " Normalization ". In previous blog we understood " Anomalies in Database " now let's understand how to remove these anomalies and how you can make your database better. Today we are going to talk about: What is Normalization Different Levels of Normalization 1 NF 2 NF 1) What is Normalization : Normalization is the process of removing anomalies from our database. What is anomaly that we have already discussed in previous part. With normalization we can also reduce redundancy in our database. Redundancy means having multiple copies of same data. There are different levels of Normalization that we will discuss now 2) Different Levels of Normalization 1 NF (First Normal Form): First Normalization Form states th...

Anomalies in Database

 Hello, and welcome to the blog. Today we are going to talk about " Anomalies in Database ". From this blog we are going to talk more about creating a database that can be used as a project and understanding more about structuring database tables in more efficient way. For that we have to have first understand what things we can do wrong while creating tables. That's why we have started with "Anomalies". Anomalies generally means flaws in the existing system. I think I am done with the overview, now let's see what we are going to cover up today: What is anomalies? Types of Anomalies Insert Update Delete let's begin with 1) What is anamolies? Anomalies are nothing but problems that can occur in poorly planned database. Generally in poorly designed database people try to put many columns in a single table. In our dat...

SQL Subqueries

Image
Hello, and welcome to the blog. In this blog we are going to talk about " Subqueries ". In the  previous blog  we have seen small topic of ALL, IN, ANY operators. Now we will see how write a query inside a query. Don't worry I will elaborate how we are gonna do it. So, we are going to talk about What is Subquery? Rules of writing outer query. Rules of writing subquery. Basic types of Subquery. Correlated Subquery. Possible number of nesting in Subquery Subquery in Update, Delete and Insert Statement Subquery with Exists keyword. let's jump into it 1) What is a subquery Subquery is a query inside a query or you can say it as nested query. It is mainly used as a part of where clause. Subquery returns data that will be used in the main query. Subquery can be used with SELECT, INSERT, UPDATE and DELETE statements. ...

IN, ALL, ANY operators in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about some operators in SQL which help us when we are are adding WHERE clause with large data. This is going to be a good practice when we are going to learn about " SUBQUERIES ". This is going to be a very small but very useful blog. So, In this blog we are going to talk about IN Operator BETWEEN Operator ALL Operator ANY Operator Currently our Employee1 table look like this: So, let's get started, 1) IN Operator The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is shorthand for multiple "OR" conditions. let's jump to the syntax: SELECT column_name FROM table WHERE coulmn_name IN (value_1,value_2,...,value_n) You can always replace va...

SQL Joins | Inner Join | Left Join | Right Join | Full Join | Self Join

Image
Hello, and welcome to the blog. In this blog we are going to talk about " Joins ". In the  previous blog  we have seen most important topic of Primary Key, Foreign Key and now its time to join some of the tables. So, In this blog we are going to talk about What is join and its purpose Type Of Joins Inner Join Left Join Right Join Full Join Self Join Let's  start with 1) What is join and its purpose There is a clause in SQL called Join. And its purpose is to combine rows from two or more tables which are connected with each other by a common column. When I say connected with each other by a common column I am talking about Foreign Key which we have covered in previous blog. Although if you haven't enforced foreign key for this blog but we do have a common column then also you can perform jo...

Identity Column, Primary Key and Foreign Key

Image
Hello, and welcome to the blog. In this blog we are going to talk about " Identity columns, Primary Key and Foreign Key ". In the  previous blog  we have seen some constraints and I told you there are more coming and here they are now. These constraints hold way too much powers as compare to what we have learnt in previous blog. Believe me if you these have arrows in your quiver, it is very easy for you to conquer the practices of designing a fully functional database. So let's not create more hype about this and start exploring theses things. In this blog we are going to talk about Identity Column Primary Key Foreign Key Let's start the discussion with 1) Identity Column: When you want to create a column whose value should get incremented every time you insert a new record then IDENTITY COLUMN is the thing you shou...

Alter command with constraints

Image
Hello, and welcome to the blog. In this blog we are going to talk about " Alter command with constraints ". In the previous blog we have seen how to create a table with constraint. If you are following the blog we already have a table "Employee", what if we have to apply constraints to that table. Don't worry "ALTER" command is there to help us. So, In this blog we are going to talk about Adding Constraints Adding null/ not null constraint Adding UNIQUE constraint Adding CHECK constraint Adding Default constraint Adding Index Knowing Constraints Renaming Constraints Removing Constraints Let's begin with, 1) Adding Constraints When we initially started, we created a simple table without any constraints here. So we are going to add constraint in that ta...