VOOZH about

URL: https://dev.to/harini_magesh_fa40041cf8d/introduction-to-sql-database-dbms-rdbms-and-sql-commands-lfd

⇱ Introduction to SQL: Database, DBMS, RDBMS, and types of SQL Commands - DEV Community


What is SQL?

SQL (Structured Query Language) is a standard language used to communicate with databases. It helps us store, retrieve, update, and delete data from a database.

In simple terms, SQL is the language that allows applications to interact with data.

What is a Database?

A Database is an organized collection of related data stored electronically.

Instead of storing information in files, databases store data in a structured manner for easy access and management.

What is DBMS?
DBMS (Database Management System)

A DBMS is software that allows users to create, manage, and manipulate databases.

It acts as an interface between the user and the database.

Responsibilities of DBMS

  • Data storage
  • Data retrieval
  • Data security
  • Backup and recovery
  • Data management

Limitations of DBMS

Traditional DBMS has some drawbacks:

  • Data redundancy (duplicate data)
  • Data inconsistency
  • Difficult relationships between data
  • Poor scalability
  • Limited multi-user support

To overcome these issues, RDBMS was introduced.

What is RDBMS?

RDBMS (Relational Database Management System) is a type of DBMS that stores data in the form of tables (relations). These tables are connected to each other using relationships.

Advantages of RDBMS
1. Reduced Data Redundancy

Data is stored only once.

2. Data Integrity

Ensures data accuracy.

3. Data Security

Provides user permissions and access control.

4. Multi-User Support

Multiple users can access data simultaneously.

5. Better Relationships

Tables can be linked using keys.

Types of SQL Commands
1. DDL (Data Definition Language)

DDL commands are used to create, modify, and delete the structure of database objects such as tables, views, and indexes.

Commands

  • CREATE – Creates a new database object such as a table, view, or database.

  • ALTER – Modifies the structure of an existing database object.

  • DROP – Permanently deletes a database object and its data.

  • TRUNCATE – Removes all records from a table while keeping the table structure intact.

2. DML (Data Manipulation Language)
DML commands are used to insert, update, and delete data stored in database tables.

Commands

  • INSERT – Adds new records into a table.

  • UPDATE – Modifies existing records in a table.

  • DELETE – Removes one or more records from a table.

3. DQL (Data Query Language)
DQL commands are used to retrieve and display data from database tables.

Commands

  • SELECT – Retrieves data from one or more tables based on specified conditions.

4. DCL (Data Control Language)
DCL commands are used to control user access and permissions on database objects.

Commands

  • GRANT – Provides specific privileges or permissions to a user.

  • REVOKE – Removes previously granted privileges from a user.

5. TCL (Transaction Control Language)
TCL commands are used to manage and control transactions in a database.

Commands

  • COMMIT – Permanently saves all changes made during the current transaction.

  • ROLLBACK – Undoes changes made during the current transaction and restores the previous state.

  • SAVEPOINT – Creates a checkpoint within a transaction that can be rolled back to later.