



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
It contains all the required files
Typology: Cheat Sheet
1 / 5
This page cannot be seen from the preview
Don't miss anything!




[Employees Table] [Departments Table] +----+--------+ +-----+-----------+ | ID | Name | | D_ID| DeptName | +----+--------+ +-----+-----------+ | 1 | Alice | | 10 | Accounts | | 2 | Bob | | 20 | HR | +----+--------+ +-----+-----------+ Join on Employees.D_ID = Departments.D_ID
SELECT E.Name, D.DeptName FROM Employees E INNER JOIN Departments D ON E.D_ID = D.D_ID;
2.2 Left Join (Left Outer Join)
SELECT E.Name, D.DeptName FROM Employees E LEFT JOIN Departments D ON E.D_ID = D.D_ID;
2.3 Right Join (Right Outer Join)
SELECT E.Name, D.DeptName FROM Employees E RIGHT JOIN Departments D ON E.D_ID = D.D_ID;
2.4 Self Join
SELECT * FROM HR_Employees;
4. Transactional Control Transactions in Databases
ACID Properties:
Transaction Control Statements Command Description BEGIN Start a transaction COMMIT Save all changes made in the transaction ROLLBACK Undo all changes since transaction began SAVEPOINT Set a point within a transaction to roll back to
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2; COMMIT; Summary Table: Joins and Views Concept Key Point Example SQL/Diagram Inner Join Only matching rows from both tables ...INNER JOIN...ON... Left Join All rows left table, match or NULL from right (^) ...LEFT JOIN...ON... Right Join All rows right table, match or NULL from left (^) ...RIGHT JOIN...ON... Self Join Join table with itself (^) FROM T1 INNER JOIN T1 T ... View Virtual table built from query (^) CREATE VIEW view_name AS SELECT ... Transaction Logical unit of work; ACID properties BEGIN; ... COMMIT;