0% found this document useful (0 votes)
7 views2 pages

SQL and DBMS Concepts Explained

Uploaded by

ranasafi004
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)
7 views2 pages

SQL and DBMS Concepts Explained

Uploaded by

ranasafi004
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

DBMS & SQL Notes (Detailed with

Examples)
Objective of SQL
SQL is used to define, manipulate, retrieve, and control data in relational databases.

Example:
CREATE TABLE Student (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);

Joins
Joins combine data from multiple tables.

Example:
SELECT [Link], c.course_name
FROM Student s
INNER JOIN Course c
ON s.course_id = c.course_id;

Functions
Functions perform calculations on data.

Example:
SELECT AVG(marks) FROM Student;

Referential Integrity
Ensures foreign key values match primary key values.

Example:
FOREIGN KEY (course_id) REFERENCES Course(course_id);
Transaction & ACID
A transaction is a logical unit of work.

Example:
BEGIN;
UPDATE Account SET balance = balance - 1000 WHERE id = 1;
UPDATE Account SET balance = balance + 1000 WHERE id = 2;
COMMIT;

Deadlock
Deadlock occurs when transactions wait forever for each other.

Example:
T1 holds A, waits for B
T2 holds B, waits for A

You might also like