SQL Fundamentals

 Intro

In this unit we are going to discuss these topics the way I understood them. You can take them as notes for a revision as I am going to use very less words but simple language. 

Macro Topics

  1. Relational Databases & SQL Basics
  2. Data Types and Table Structures 

Micro Topics

  1. What is a database, table, row, column
  2. RDBMS concepts (MySQL, PostgreSQL, SQL Server)
  3. Primary key vs foreign key
  4. NULL values and NULL handling
  5. Data types:
    1. Numeric (INT, FLOAT, DECIMAL)
    2. String (VARCHAR, CHAR, TEXT)
    3. Date & Time (DATE, TIME, TIMESTAMP)
    4. Boolean
  6. Schema and database structure 
  7. Case sensitivity in SQL
  8. SQL keywords vs identifiers
  9. SQL execution order 

Let us start from the basics, we will move one step at a time. 

What is SQL: Standard Query Language (SQL) is the standard language used to interact with relational databases. 

Database: A database is an organised collection of data. 

Relational Database: A relational database is an organised collection of data in tables. These tables are made up of rows and columns

Rows: Rows represent individual records in a table. 

Columns: Columns represent the attributes or fields that describe each record. 

This is a table in a database with 7 rows (horizontal) and 4 columns (vertical). 

Schema: The schema defines the overall structure of the database, including its tables, columns, data types, relationships and constraints. 

So in simple terms SQL is a tool to manage data which is in the form of tables in a database. 

What are MySQL, PostgreSQL, SQLite, etc?

SQL is a language to interact with a relational DBMS, and there are different database management systems available in the market that are used to manage data. So MySQL, PostgreSQL, SQLite etc are different database management systems. The key is that every DBMS uses a slightly different SQL syntax. For instance Microsoft Excel and Google Sheets, in each you can work with data but some functions are slightly different.  

Primary Key and Foreign Key

NULL values and NULL handling

What I understood? 

What is a data type?

A data type in SQL means the kind of data stored in a database. There are different kinds of data that we store in a database for example integers, numbers, text, date etc. So each kind of data is a data type. 

In another way a column with an int data type can only accept integer numbers. 

Common Data Types in SQL

int/integer : integer numbers

serial: autoincrementing integer

char/varchar/text : all store character text but in a slightly different way

date : stores date in yyyy-mm-dd format

time : stores time in hh-mm-ss format

timestamp: stores data and time

boolean/bool : logical bollean (true/false)

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top