Main Terms
• DATA VALUE
• RECORDS
• FIELDS
• ENTITY
• HORIZONTAL AND VERTICAL ENTITY
SQL
Non
Declarative
Procedural
Main
components
DDL DML DCL TCL
DDL
Create Alter Drop Rename Truncate
CREATE statement
Used for creating entire databases and database objects as tables
CREATE object_type object_name;
ALTER statement
• Used when altering existing objects
• ADD
• Remove
• Rename
ALTER TABLE sales ADD COLUMN
date_of_purchase DATE;
DROP statement
• Used for deleting a database object
DROP object_type object_name;
RENAME statement
• Allows you to rename an object
RENAME object_type object_name TO new_object_name;
TRUNCATE statement
• Instead of deleting an entire table through DROP,
we can also remove its data and continue to have
the table as an object in the database
TRUNCATE object_type object_name;;
Keywords/Reserve words
• Add
• Create
• Alter
DML
Select Insert Update Delete
SELECT Statement
• Used to retrieve data from database
objects, like tables
SELECT * FROM sales;
INSERT statement
• Used to insert data into tables
INSERT INTO… VALUES…;
UPDATE statement
• Allows you to renew existing data of your
tables
UPDATE sales SET date_of_purchase = ‘2017-12-12’
WHERE purchase_number = 1;
DELETE statement
• Functions similarly to the TRUNCATE statement
DELETE FROM table_Name;
Key Points for DML
• Select --------- From
• Insert------------Into-------values
• Update-------- set ---------values
• Delete---------- From-------where
DCL
Grant Revoke
TCL
Commit Rollback
Relational
Schemas
Primary Foreign Unique
Key Key Key
A column whose value exist and is
unique for each record in a table
Relational
Schemas
Primary Foreign Unique
Key Key Key
Identifies the relationships
between tables
Relational
Schemas
Primary Key Foreign Key Unique Key
Used where you would not like to specify
that you don’t want to see duplicate
data in a field
Datatype
String, Date
Numeric
and time
String, Date
and time
CHAR VARCHAR DATE DATETIME TIMESTAMP
Numeric
data types
INTEGER DECIMAL NUMERIC FLOAT DOUBLE