
DBMS-2
Presentation
•
Computers
•
University
•
Hard
Veda V
Used 8+ times
FREE Resource
24 Slides • 4 Questions
1
DBMS-Concepts
(Session 2)
By
V.Veda Sri
Asst.Professor
Dept. of Comp.Science
RBVRR Women's College
2
SQL JOIN
In SQL, JOIN clause is used to combine the records from two or more tables in a database.
Types of SQL JOIN: INNER JOIN, LEFT JOIN, RIGHT JOIN ,FULL JOIN.
3
4
1. INNER JOIN
In SQL, INNER JOIN selects records that have matching values in both tables as long as the condition is satisfied. It returns the combination of all rows from both the tables where the condition satisfies.
Syntax
SELECT table1.column1, table1.column2, table2.column1,.... FROM table1 INNER JOIN table2 ON table1.matching_column = table2.matching_column;
5
Query
SELECT EMPLOYEE.EMP_NAME,
PROJECT.DEPARTMENT FROM EMPLOYEE
INNER JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;
6
2. LEFT JOIN
The SQL left join returns all the values from left table and the matching values from the right table. If there is no matching join value, it will return NULL.
Syntax
SELECT table1.column1, table1.column2, table2.column1,.... FROM table1 LEFT JOIN table2 ON table1.matching_column = table2.matching_column;
7
Query
SELECT EMPLOYEE.EMP_NAME,
PROJECT.DEPARTMENT
FROM EMPLOYEE
LEFT JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;
8
3. RIGHT JOIN
In SQL, RIGHT JOIN returns all the values from the values from the rows of right table and the matched values from the left table. If there is no matching in both tables, it will return NULL.
Syntax
SELECT table1.column1, table1.column2, table2.column1,.... FROM table1 RIGHT JOIN table2 ON table1.matching_column = table2.matching_column;
9
Query
SELECT EMPLOYEE.EMP_NAME,
PROJECT.DEPARTMENT
FROM EMPLOYEE
RIGHT JOIN PROJECT ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;
10
4. FULL JOIN
In SQL, FULL JOIN is the result of a combination of both left and right outer join. Join tables have all the records from both tables. It puts NULL on the place of matches not found.
Syntax
SELECT table1.column1, table1.column2, table2.column1,.... FROM table1 FULL JOIN table2 ON table1.matching_column = table2.matching_column;
11
Query
SELECT EMPLOYEE.EMP_NAME,
PROJECT.DEPARTMENT
FROM EMPLOYEE
FULL JOIN PROJECT ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;
12
13
Multiple Choice
Insert the missing parts in the JOIN clause to join the two tables Orders and Customers, using the CustomerID field in both tables as the relationship between the two tables.
SELECT *
FROM Orders
LEFT JOIN Customers
_______=________
ON Orders.CustomerID=
Customers.CustomerID;
Customers.CustomerID=
orders.customerID
Orders.CustomerID=
Customers.CustomerID;
ON Customers.CustomerID=
Orders.CustomerID
14
Multiple Choice
Choose the correct JOIN clause to select all the records from the Customers table plus all the matches in the Orders table.
SELECT *
FROM Orders
------------------------
ON Orders.CustomerID=Customers.CustomerID;
JOIN Customers
RIGHT JOIN Customers
RIGHT JOIN Orders
OUTER JOIN Customers
15
Multiple Choice
The LEFT JOIN keyword returns all records from the left table (Customers), even if there are ______ in the right table (Orders).
matches
no matches
16
Multiple Choice
The FULL OUTER JOIN keyword returns all matching records from both tables whether the other table _______.
only matches
only not matches
matches or not
None
17
18
SQL Constraints
SQL constraints are used to specify rules for the data in a table.
This ensures the accuracy and reliability of the data in the table.
Constraints can be column level or table level.
19
The following constraints are commonly used in SQL
NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE.
FOREIGN KEY - Uniquely identifies a row/record in another table
CHECK - Ensures that all values in a column satisfies a specific condition
DEFAULT - Sets a default value for a column when no value is specified
INDEX - Used to create and retrieve data from the database very quickly
20
Example
CREATE TABLE Persons (
ID int NOT NULL UNIQUE/PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255) NOT NULL,
Age int CHECK (Age>=18),
City varchar(255) DEFAULT 'Sandnes'
);
21
1. Domain constraints
Domain constraints can be defined as the definition of a valid set of values for an attribute.
The data type of domain includes string, character, integer, time, date, currency, etc. The value of the attribute must be available in the corresponding domain.
22
Example
23
2. Entity integrity constraints
The entity integrity constraint states that primary key value can't be null.
This is because the primary key value is used to identify individual rows in relation and if the primary key has a null value, then we can't identify those rows.
A table can contain a null value other than the primary key field.
24
Example
25
3. Referential Integrity Constraints
A referential integrity constraint is specified between two tables.
In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.
26
Example
27
4. Key constraints
Keys are the entity set that is used to identify an entity within its entity set uniquely.
An entity set can have multiple keys, but out of which one key will be the primary key. A primary key can contain a unique and null value in the relational table.
28
Example
DBMS-Concepts
(Session 2)
By
V.Veda Sri
Asst.Professor
Dept. of Comp.Science
RBVRR Women's College
Show answer
Auto Play
Slide 1 / 28
SLIDE
Similar Resources on Wayground
21 questions
Pengantar Kewirausahaan-1
Presentation
•
University
20 questions
MAZE PUZZLE ORIENTATION APRIL
Presentation
•
University
20 questions
BASIC MULTIPLE CHOICE QUESTIONS
Presentation
•
KG
20 questions
Pengantar Perpajakan
Presentation
•
University
22 questions
Kuis Akun Belajar.id-Revisi
Presentation
•
Professional Development
24 questions
AY21/22 Primary Coaching Resource 2 : Familiarity Ops
Presentation
•
Professional Development
22 questions
Connectors
Presentation
•
University
22 questions
Permainan bola voli kelas X
Presentation
•
KG - University
Popular Resources on Wayground
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
10 questions
Cinco de Mayo Trivia Questions
Interactive video
•
3rd - 5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
13 questions
Cinco de mayo
Interactive video
•
6th - 8th Grade
20 questions
Math Review
Quiz
•
3rd Grade
30 questions
GVMS House Trivia 2026
Quiz
•
6th - 8th Grade
Discover more resources for Computers
55 questions
Post Malone Addtion (Tres)
Quiz
•
12th Grade - University
20 questions
Disney Trivia
Quiz
•
University
50 questions
AP Biology Exam Review 2017
Quiz
•
11th Grade - University
24 questions
5th Grade Math EOG Review
Quiz
•
KG - University
12 questions
Star Wars Trivia - Easy
Quiz
•
KG - University
215 questions
8th Physical Science GA Milestones Review
Quiz
•
KG - University
40 questions
Famous Logos
Quiz
•
7th Grade - University
14 questions
(5-3) 710 Mean, Median, Mode & Range Quick Check
Quiz
•
6th Grade - University