0% found this document useful (0 votes)
8 views3 pages

2.2 languages

Relationa langauages

Uploaded by

amsini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

2.2 languages

Relationa langauages

Uploaded by

amsini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Languages

In Data Modeling, languages are essential for defining, managing, and manipulating data
structures in a Database Management System (DBMS). These languages help users interact
with the database to perform various tasks such as creating tables, inserting data, querying
data, and ensuring data security and consistency. Below are the key reasons why languages
are crucial in data modeling.The main types of languages in DBMS are:

1. Data Definition Language (DDL)


2. Data Manipulation Language (DML)
3. Data Control Language (DCL)
4. Transaction Control Language (TCL)
5. Data Query Language (DQL)

1. Data Definition Language (DDL)

DDL is used to define the structure of the database, such as tables, schemas, indexes, and
constraints.

Key Commands in DDL:


Command Description Example

Creates a new table, database, or CREATE TABLE Student (ID INT, Name
CREATE
index. VARCHAR(50));

Modifies an existing table


ALTER ALTER TABLE Student ADD Age INT;
structure.

DROP Deletes a table or database. DROP TABLE Student;

TRUNCATE Deletes all records from a table. TRUNCATE TABLE Student;

Example of DDL Command:


Sql code
CREATE TABLE Employee (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
Salary INT
);

2. Data Manipulation Language (DML)

DML is used to manipulate the data in the database, such as inserting, updating, or deleting
records.
Key Commands in DML:
Command Description Example

INSERT INTO Student (ID, Name) VALUES (1,


INSERT Adds new records to a table. 'John');

UPDATE Modifies existing records. UPDATE Student SET Name = 'Doe' WHERE ID = 1;

Removes records from a


DELETE DELETE FROM Student WHERE ID = 1;
table.

Example of DML Command:


Sql code
INSERT INTO Employee (EmpID, Name, Salary)
VALUES (101, 'Alice', 50000);

3. Data Control Language (DCL)

DCL is used to control access to the database by granting or revoking permissions.

Key Commands in DCL:


Command Description Example

GRANT Gives permission to users. GRANT SELECT ON Employee TO User1;

REVOKE Removes permission from users. REVOKE SELECT ON Employee FROM User1;

Example of DCL Command:


Sql code
GRANT SELECT, INSERT ON Employee TO User1;

4. Transaction Control Language (TCL)

TCL is used to manage transactions in the database. Transactions are a set of operations that
must be executed as a single unit.

Key Commands in TCL:


Command Description Example

COMMIT Saves the transaction permanently. COMMIT;

ROLLBACK Reverts the transaction to the last commit. ROLLBACK;

SAVEPOINT Creates a point within a transaction to rollback to. SAVEPOINT Save1;

💡 Example of TCL Command:


sql code
BEGIN TRANSACTION;
INSERT INTO Employee (EmpID, Name, Salary) VALUES (102, 'Bob', 60000);
COMMIT;

5. Data Query Language (DQL)

DQL is used to retrieve data from the database. It focuses on querying the data using the
SELECT statement.

Key Command in DQL:


Command Description Example

SELECT Retrieves data from one or more tables. SELECT * FROM Employee;

Example of DQL Command:


Sql code
SELECT Name, Salary FROM Employee WHERE Salary > 50000;

Summary of DBMS Languages:

Type of Language Purpose Example Commands

DDL (Data Definition) Defines the database structure. CREATE, ALTER, DROP

DML (Data Manipulation) Manipulates data in the database. INSERT, UPDATE, DELETE

DCL (Data Control) Controls user access to the database. GRANT, REVOKE

TCL (Transaction Control) Manages transactions in the database. COMMIT, ROLLBACK, SAVEPOINT

DQL (Data Query) Queries data from the database. SELECT

Importance of DBMS Languages in Data Modeling:

1. DDL helps in defining the structure and constraints of the data model.
2. DML allows users to manipulate and update the data within the model.
3. DCL ensures security and access control of the database.
4. TCL manages transactions and maintains consistency.
5. DQL helps in retrieving and analyzing the stored data

You might also like