Saturday, 14 April 2018

Crash Course in SQL Part 1: What is SQL

Most people pronounce 'SQL' as 'sequel' although 'S Q L' is equally valid

It has different meanings:

One is 'Structured Query Language', which is the subject of this 'crash' course.

Another common one  is as a shorthand for Microsoft SQL Server, which is a set of database software products produced by Microsoft.

Microsoft SQL Server has its own version of Structured Query Language which it calls 'Transact SQL' or 'T-SQL' for short

Other software products have their own variations of Structured Query Language. For example Oracle provides 'PL/SQL'

Although there are slight differences between the different versions of SQL, the core is exactly the same. So if you learn SQL on one product you can adapt quickly to others.

Structured Query Language is a way of interacting with relational databases

Relational databases are those which can have many tables. In theory this will be designed in such as way as  to avoid duplication of data. And each table will have a unique key which allows it to be related to other tables

In real life the design and content of databases can get a bit more messy, for various reasons.

SQL is essentially an instruction, written out as text, which is 'thrown' at a database. The database will attempt to respond to the instruction

How the instructions are written and thrown - and where the results are displayed - will depend on what tools you have available, Typically there will be a utility (such as SQL Server Management Studio) which allows these things to be done in different panels visible together on the same computer screen

So we would write (or retrieve an existing) SQL script in one panel, hit an Execute button, and see the results displayed in another panel

.
The beauty of SQL is that the core is relatively simple

There are different types of instruction for different purposes

Computer people give these grand titles such as

  • Data Manipulation Language (DML)
  • Data Definition Language (DDL)
  • Data Control Language (DCL)


These are basically just groups of instructions for either doing things with data or setting things up


SQL Data Manipulation Language (DML) is mainly based around the following four types of instruction
  • SELECT
  • DELETE
  • INSERT
  • UPDATE
These instructions are used for looking at, getting rid of, collecting or changing data

Of these,  SELECT is the most often used as it is the one that actually gives the answers to any questions


SQL Data Definition Language (DDL) is mainly based around the following three types of instruction
  • CREATE 
  • ALTER
  • DROP

These instructions are the ones needed to set things up - and then changing them again later. We will not spend much time looking at these on this crash course

SQL Data Control Language (DCL)is mainly based around the following three types of instruction
  • GRANT 
  • REVOKE 
  • DENY

These are the instruction used to set out who can do what. Computer people are obsessed with stopping other people doing things, or looking into the innards of their creations. It's a shame as otherwise they are good people to have around. We will not spend any time looking at these 'permission' issues on this crash course. Just be ready to hit this nonsense when you try to use anything in the workplace

That is the end of Part 1.
In Part 2 we will look at SELECT  - the main big thing you will need to master

Here are a few links which may help flesh out the content of Part 1

https://www.w3schools.com/sql/sql_intro.asp

https://www.infoworld.com/article/3219795/sql/what-is-sql-structured-query-language-explained.html

https://bytescout.com/blog/what-is-sql-and-what-is-it-used-for.html

https://www.ntchosting.com/encyclopedia/databases/structured-query-language/

https://searchsqlserver.techtarget.com/definition/SQL







No comments:

Post a Comment

Crash Course in SQL Part 2: SELECT

The SQL SELECT instruction is the most important single thing to master It is the instruction that actually gives the answers to any que...