BDST 122 RDBMS
BDST 122 RDBMS
UNIT : 1
Foundations of SQL and database design
1. Data Integrity
Accuracy and Consistency: Ensure that data is accurate, consistent, and
reliable. Implement integrity constraints such as primary keys, foreign keys,
and unique constraints to maintain relationships and prevent data anomalies.
Validation Rules: Use validation rules to enforce correct data entry,
minimizing errors and inconsistencies.
2. Security
Access Control: Implement robust access control mechanisms to ensure that
only authorized users have access to specific data. Use role-based access
control (RBAC) and ensure proper user authentication.
1. Basic Syntax
Two Tables:
1. INNER JOIN
FROM employees
ON employees.department_id = departments.department_id;
Result:
name department_name
Alice HR
Bob IT
Charlie Marketing
FROM employees
ON employees.department_id = departments.department_id;
Result:
name department_name
Alice HR
Bob IT
Charlie Marketing
David NULL
3. RIGHT JOIN (or RIGHT OUTER JOIN)
FROM employees
ON employees.department_id = departments.department_id;
Result:
name department_name
Alice HR
Bob IT
Charlie Marketing
NULL Finance
FROM employees
ON employees.department_id = departments.department_id;
Result:
name department_name
Alice HR
Bob IT
Charlie Marketing
David NULL
NULL Finance
WHERE : - - -
The WHERE clause is used to filter records.
It is used to extract only those records that full fill a specified condition.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example :----
SELECT * FROM marks
WHERE student_id = 1;
2) UPDATE Statement: - - -
The UPDATE statement is used to modify the existing records in a table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Example :
UPDATE Customers
SET ContactName = 'Ram', City= 'pune'
WHERE CustomerID = 1;
3) DELETE Statement
The DELETE statement is used to delete existing records in a table.
DELETE Syntax
DELETE FROM table_name WHERE condition;
Example:
DELETE FROM Customers WHERE CustomerName='Ram';
Delete All Records
DELETE FROM table_name;
Example :
DELETE FROM Customers;
Delete a Table
To delete the table completely, use the DROP TABLE statement:
Example : Remove the Customers table:
DROP TABLE Customers;