What is Database?
Database is a collection of interrelated data.
What is DBMS?
DBMS (Database Management System) is software used to create, manage, and organize
databases.
What is RDBMS?
● RDBMS (Relational Database Management System) - is a DBMS based on the
concept of tables (also called relations).
● Data is organized into tables (also known as relations) with rows (records) and
columns (attributes).
● Eg - MySQL, PostgreSQL, Oracle etc.
What is SQL?
SQL is Structured Query Language - used to store, manipulate and retrieve data from
RDBMS.
(It is not a database, it is a language used to interact with database)
We use SQL for CRUD Operations :
● CREATE - To create databases, tables, insert tuples in tables etc
● READ - To read data present in the database.
● UPDATE - Modify already inserted data.
● DELETE - Delete database, table or specific data point/tuple/row or multiple rows.
*Note - SQL keywords are NOT case sensitive. Eg: select is the same as SELECT in SQL.
SQL v/s MySQL
SQL is a language used to perform CRUD operations in Relational DB, while MySQL is a
RDBMS that uses SQL.
,SQL Data Types
In SQL, data types define the kind of data that can be stored in a column or variable.
To See all data types of MYSQL, visit :
https://dev.mysql.com/doc/refman/8.0/en/data-types.html
Here are the frequently used SQL data types:
DATATYPE DESCRIPTION USAGE
CHAR string(0-255), can store characters of fixed length CHAR(50)
VARCHAR string(0-255), can store characters up to given length VARCHAR(50)
BLOB string(0-65535), can store binary large object BLOB(1000)
INT integer( -2,147,483,648 to 2,147,483,647 ) INT
TINYINT integer(-128 to 127) TINYINT
BIGINT integer( -9,223,372,036,854,775,808 to BIGINT
9,223,372,036,854,775,807 )
BIT can store x-bit values. x can range from 1 to 64 BIT(2)
FLOAT Decimal number - with precision to 23 digits FLOAT
DOUBLE Decimal number - with 24 to 53 digits DOUBLE
BOOLEAN Boolean values 0 or 1 BOOLEAN
DATE date in format of YYYY-MM-DD ranging from DATE
1000-01-01 to 9999-12-31
TIME HH:MM:SS TIME
YEAR year in 4 digits format ranging from 1901 to 2155 YEAR
*Note - CHAR is for fixed length & VARCHAR is for variable length strings. Generally,
VARCHAR is better as it only occupies necessary memory & works more efficiently.
We can also use UNSIGNED with datatypes when we only have positive values to add.
Eg - UNSIGNED INT
Types of SQL Commands:
, 1. DQL (Data Query Language) : Used to retrieve data from databases. (SELECT)
2. DDL (Data Definition Language) : Used to create, alter, and delete database objects
like tables, indexes, etc. (CREATE, DROP, ALTER, RENAME, TRUNCATE)
3. DML (Data Manipulation Language): Used to modify the database. (INSERT,
UPDATE, DELETE)
4. DCL (Data Control Language): Used to grant & revoke permissions. (GRANT,
REVOKE)
5. TCL (Transaction Control Language): Used to manage transactions. (COMMIT,
ROLLBACK, START TRANSACTIONS, SAVEPOINT)
1. Data Definition Language (DDL)
Data Definition Language (DDL) is a subset of SQL (Structured Query Language)
responsible for defining and managing the structure of databases and their objects.
DDL commands enable you to create, modify, and delete database objects like tables,
indexes, constraints, and more.
Key DDL Commands are:
● CREATE TABLE:
○ Used to create a new table in the database.
○ Specifies the table name, column names, data types, constraints, and more.
○ Example:
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50),
salary DECIMAL(10, 2));
● ALTER TABLE:
○ Used to modify the structure of an existing table.
○ You can add, modify, or drop columns, constraints, and more.
○ Example: ALTER TABLE employees ADD COLUMN email VARCHAR(100);
● DROP TABLE:
○ Used to delete an existing table along with its data and structure.
○ Example: DROP TABLE employees;
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller shreelgandhi. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.09. You're not tied to anything after your purchase.