SQL Is Used Often To Query, Insert, Update, and Modify Data. at A Basic Level SQL Is A Method For Communicating Between You and The Database
SQL Is Used Often To Query, Insert, Update, and Modify Data. at A Basic Level SQL Is A Method For Communicating Between You and The Database
SQL Is Used Often To Query, Insert, Update, and Modify Data. at A Basic Level SQL Is A Method For Communicating Between You and The Database
SQL was developed by IBM in 1970s. It was initially called SEQL (Structured
English Query Language)
SQL - Structured Query Language - SQL is used often to query, insert, update,
and modify data. At a basic level SQL is a method for communicating between
you and the database.
DBMS - A DBMS is software that manages the database. Some of the commonly
used DBMS (software) are MS ACCESS, MySQL, Oracle, and others. You use a
Database Management System (DBMS) to store the data you collect from
various sources, and SQL to manipulate and access the particular data you want
in an efficient way.
Types of DBMS
There are two types of DBMS.
Some of the RDBMS commonly used are MySQL, MSSQL, Oracle, and others.
TABLES in SQL
Data warehouse occupies large memory and has multiple subject data. Data
mart is a subset of data warehouse and has department wise data
DATA MODELLING
Different headers in a table are called dimensions and the id is called the
primary key that doesn’t allow duplicates.
DATABASE NORMALIZATION
Eg
BEGIN TRANSACTIONS
To Roll back the transaction (or to undo the changes in the database)
ROLLBACK TRANSACTION
Commit statement permanently puts the values in the database
COMMIT TRANSACTION
SQL Constraints
SQL constraints are used to specify rules for the data in a table.
Constraints are used to limit the type of data that can go into a table. This
ensures the accuracy and reliability of the data in the table. If there is any
violation between the constraint and the data action, the action is aborted.
Constraints can be column level or table level. Column level constraints apply to
a column, and table level constraints apply to the whole table.
FOREIGN KEY - Prevents actions that would destroy links between tables
CREATE INDEX - Used to create and retrieve data from the database very
quickly
ACID PROPERTIES
ATOMICITY simply signifies that the transaction that one is going to commit is
either complete or not complete.
CONSISTENCY simply means that changes to the values of an instance are
consistent with the values in another instance
Keys are an integral element of Relational database model. These are used in
identifying and establishing relationships between tables. Moreover, keys are
necessary in recognizing any row of data or record in a table. These can either
be a group of aspects or a single aspect wherein the combination of the same
would act as a key.
Primary Key
This is the first key that helps in identifying a single instance of an entity, in a
distinct manner. There can be numerous keys present in a table, which can be
seen in the “Personal Information” table. That one key that is most suitable
among other key attributes in a table becomes the Primary Key.
For instance, if we take the Personal Information table, we can see that along
with the Social_Security_Number, the License_Number too can become the
Primary Key as both these attributes are unique to respective individuals. The
selection of any primary key depends on the developer and the specific needs.
Candidate Key
Foreign Key
Employee
Name
Employee_ID
Social_Security_Number
License_Number
Department_ID
Department
Department_ID
Department_Head
In these two tables, we see that every employee is from a separate department,
which is again an individual entity and therefore cannot be added to the same
table of “Employee”. Therefore, it has been added separately to “Department”
table. So, to link both these tables, the Primary Key of one table is added to
another. So, in the Department table, Department_ID is the Primary Key, which
has been added as a Foreign to the Employee table that helps in relating these
two tables.
CLAUSE
1. Select
2. From
3. Distinct – Keyword use to remove the duplicates
4. 4. WHERE
5.
Logical Operators
LIKE OPERATOR
% any no of characters
_ single character
Eg: SELECT * FROM customers WHERE address LIKE ‘%trail%’ OR WHERE address LIKE ‘%avenue%’
Frequent commands used in SQL
1. DDL commands
DDL stands for Data Definition Language. It includes the set of commands that you use to perform
various tasks related to data definition. You use these commands to specify the structure of the
storage and methods through which you can access the database system .
DML stands for Data Manipulation Language. As the name suggests, it consists of commands which
you use to manipulate the data.
Deletion
Insertion
Retrieval
Modification
3. TCL commands
TCL stands for Transaction Control Language. As the name says, you use these commands to control
and manage transactions.
One complete unit of work that involves various steps is called a transaction. You use these
commands for the following purposes: