What is DBMS ?
### DBMS (Database Management System)
A **Database Management System (DBMS)** is software that interacts with the user, applications, and the database itself to capture and analyze data. A DBMS allows users to create, read, update, and delete data in a database. It ensures data integrity, security, and concurrency while providing support for data manipulation and retrieval.
#### Types of DBMS
1. **Hierarchical DBMS**:
- Data is organized in a tree-like structure.
- Example: IBM Information Management System (IMS).
2. **Network DBMS**:
- Data is organized in a graph, allowing many-to-many relationships.
- Example: Integrated Data Store (IDS).
3. **Relational DBMS (RDBMS)**:
- Data is stored in tables (relations) and can be linked based on data common to each.
- Examples: MySQL, PostgreSQL, Oracle, Microsoft SQL Server.
4. **Object-oriented DBMS (OODBMS)**:
- Data is stored in objects, similar to object-oriented programming.
- Example: db4o, ObjectDB.
5. **NoSQL DBMS**:
- Designed for unstructured data and provides a mechanism for storage and retrieval of data that is modeled in means other than tabular relations used in relational databases.
- Examples: MongoDB, Cassandra, Redis.
### SQL (Structured Query Language)
**SQL** is a standard programming language specifically designed for managing and manipulating databases. SQL is used to perform various operations on the data within a relational database.
#### Basic SQL Commands
1. **Data Definition Language (DDL)**:
- Commands that define the structure of the database.
- Examples:
- `CREATE TABLE`: Creates a new table.
- `ALTER TABLE`: Modifies an existing table.
- `DROP TABLE`: Deletes a table.
```sql
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
position VARCHAR(100),
salary DECIMAL(10, 2)
);
```
2. **Data Manipulation Language (DML)**:
- Commands that manipulate the data within the database.
- Examples:
- `INSERT INTO`: Adds new data into a table.
- `UPDATE`: Modifies existing data within a table.
- `DELETE`: Removes data from a table.
- `SELECT`: Retrieves data from one or more tables.
```sql
INSERT INTO employees (id, name, position, salary) VALUES (1, 'John Doe', 'Manager', 60000.00);
```
3. **Data Control Language (DCL)**:
- Commands that control access to the data within the database.
- Examples:
- `GRANT`: Gives user's access privileges to the database.
- `REVOKE`: Takes back permissions granted to the user.
```sql
GRANT SELECT ON employees TO user_name;
```
4. **Transaction Control Language (TCL)**:
- Commands that manage transactions within the database.
- Examples:
- `COMMIT`: Saves the transaction permanently in the database.
- `ROLLBACK`: Restores the database to its last committed state.
- `SAVEPOINT`: Sets a savepoint within a transaction to which one can rollback.
```sql
BEGIN TRANSACTION;
UPDATE employees SET salary = salary * 1.10 WHERE position = 'Manager';
COMMIT;
```
#### Example Languages for DBMS
1. **SQL**:
- Standard language for relational databases.
- Examples: MySQL, PostgreSQL, Oracle SQL.
2. **PL/SQL** (Procedural Language/SQL):
- Oracle Corporation's procedural extension for SQL.
- Used in Oracle databases.
3. **T-SQL** (Transact-SQL):
- Microsoft's and Sybase's proprietary extension to SQL.
- Used in Microsoft SQL Server and Sybase ASE.
4. **MongoDB Query Language (MQL)**:
- Used for querying MongoDB NoSQL databases.
5. **CQL (Cassandra Query Language)**:
- Used for querying Apache Cassandra.
These languages and commands provide the means to create, modify, manage, and interact with databases effectively.
Comments
Post a Comment