Vikas Rajput Profile picture
Feb 8 โ€ข 10 tweets โ€ข 3 min read
Beginner Guide to Views in SQL: ๐Ÿงต๐Ÿ‘‡
1. Definition

- View contains a subset of records from a table based on given conditions

- Consider View as a Virtual table with restricted data, it is not a physical table
2. Usecases

- Consider a situation where we don't want to give full access to the base table

- In such case, we can create a view which can have limited rows and columns from the base table

- Later, View can be used as a table in all DQL statements
3. How to Create a View?

- Syntax:
CREATE VIEW <view-name> AS <query>;

- Using the above syntax, we can create views

- View always needs a select query in which we can mention the columns that need to be shown and the condition to filter the records
4. Example

- Let's create a View to see only employees living in Mexico and Hide the salary column in a view

- As shown in the above syntax, let's add a query with selected columns and filter conditions as shown below

Eg:
- Here, EMPLOYEE_TABLE containing all records of employees including the salary of all employees and the city they live in, as shown below

- And, also see the records in View as a normal table via a Select query

Eg:
5. Edit and Delete a View

Edit:
- CREATE OR REPLACE <view> from <query>

Delete:
- DROP VIEW <view-name>
6. Advantages

- Easily hide the complexity of the query and the user can directly interact with a view like a table

- Hide raw data and show aggregated data

- Apply row/column level security
7. Disadvantages

- View cannot be created on temporary tables

- It cannot have parameters

- Cannot update records in view if the underlying query contains aggregate functions, Distinct, group by, union, etc

- Depending on the DB vendor it can have many more limitations
Thank you for Reading!

I help people get started with Backend Development.

Follow me @vikasrajputin for more.

If you find this thread helpful then Like/Retweet the first tweet below:

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Vikas Rajput

Vikas Rajput Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @vikasrajputin

Feb 6
You can either pay > 1000 USD to a bootcamp to learn Java

or You can learn it for free from Youtube!!

Here's a List of 4 Top Quality Resources to Master Java:
Read 6 tweets
Feb 3
OOP Concepts are the Fundamentals of Programming Languages like Java, Python (and many others)

Here's a Dead Simple Guide to Understand It:
There are six different concepts in OOP:

1. Object
2. Class
3. Inheritance
4. Encapsulation
5. Abstraction
6. Polymorphism

Note: In this thread, we'll try to understand it from Java's standpoint.
1. Object

Every real-world entity is an object.

An object has Behaviour (things it does or performs) and Attributes (things that describe it).

For eg: A Chair object can have behaviour like Movement, Height Adjustment & Attributes like Color, Make & Model, and Price.
Read 10 tweets
Feb 1
6 Online SQL IDEs to Practice SQL:
1. SQL Fiddle

๐Ÿ”— http: // sqlfiddle. com/
2. Programiz

๐Ÿ”— https: //www. programiz. com/sql/online-compiler/
Read 8 tweets
Jan 30
SQL: What are DDL, DML, DQL, DCL and TCL? ๐Ÿงต๐Ÿ‘‡
1. Introduction

The SQL commands are categorized into the following categories:

DDL - Data Definition Language
DML - Data Manipulation Language
DQL - Data Query Language
DCL - Data Control Language
TCL - Transaction Control Language

Let's see each of them in detail.
2. DDL

Queries like - CREATE, DROP, TRUNCATE, and ALTER fall into this category because they all manage the structure of DB Objects in some way.

For eg: CREATE command creates the structure of a table, DROP command removes the table structure.
Read 8 tweets
Jan 27
Factory Design Pattern is one of the most widely used patterns in Programming Languages like Java, Javascript, Python, etc.

Here's the simplest explanation to what it is:
1. The factory design pattern is a way to create objects without specifying the exact class of object.

This is done by defining a separate factory class that has a method for creating objects.

Let understand this from Java's perspective.
2. To implement the factory design pattern, we need to create an interface that defines the contract for the objects that will be created.

This interface should specify the methods that will be available on the objects.
Read 11 tweets
Jan 4
If you want to master SQL, then start with these youtube videos:
1. SQL Tutorial - Full Course for Beginner

Probably the most popular SQL course on youtube, starting from scratch to explaining advanced topics it is a must-watch.

Duration - 4:20 hrs
Database Used in Tutorial - MySQL

2. MySQL Tutorial for Beginner Full course

Another great video where SQL is explained from scratch this course is using some pretty simple examples and beginner friendly

Duration - 3:10 hrs
Database Used - MySQL

Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(