DMS (22319) - Chapter 2 Notes
DMS (22319) - Chapter 2 Notes
Mr. S. Y. Divekar
For example:
In the EMPLOYEE table, for (EMPLOEE_ID,
EMPLOYEE_NAME) the name of two employees can
be the same, but their EMPLYEE_ID can't be the
same. Hence, this combination can also be a key.
The super key would be EMPLOYEE-ID,
(EMPLOYEE_ID, EMPLOYEE-NAME), etc…
Mr. S. Y. Divekar
Properties of Candidate Keys:
It must contain unique values
Candidate key may have multiple attributes
Must not contain null values
It should contain minimum fields to ensure uniqueness
Uniquely identify each record in a table
Redundancy
Number of Tables
Complexity
Database Management System (DMS) Mr. S. Y. Divekar
First Normal Form:
“A table is said to be in First Normal Form (1NF) if and only if
each attribute of the relation is atomic. ”
OR
“A relation R is said to be in first normal form (1NF) if the
domain of all attributes of R are atomic.”
That is,
Each row in a table should be identified by primary key (a unique column
value or group of unique column values)
No rows of data should have repeating group of column values.
First Normal Form (1NF) enforces these criteria:
Eliminate repeating groups in individual tables.
Create a separate table for each set of related data.
Identify each set of related data with a primary key
If we observe the data in the table above it satisfies 3NF. But LECTURER and
BOOKS are two independent entities here.
There is no relationship between Lecturer and Books. In the above example,
either Alex or Bosco can teach Mathematics. For Mathematics subject , student
can refer either ‘Maths Book1’ or ‘Maths Book2’.
i.e.:
SUBJECT –> LECTURER
SUBJECT–>BOOKS
Hence it removes the multi-valued dependency and confusion around the data.
Thus the table is in 4NF.
Database Management System (DMS) Mr. S. Y. Divekar
Fifth Normal Form:
“A relation is in Fifth Normal Form (5NF), if it is in 4NF, and
won’t have lossless decomposition into smaller tables.. ”
The 5NF (Fifth Normal Form) is also known as project-join normal
form.
A relation is in 5NF if it is in 4NF and not contains any join
dependency and joining should be lossless.
5NF is satisfied when all the tables are broken into as many
tables as possible in order to avoid redundancy.
Syntax:
RENAME OldTableName TO NewTableName;
Example:
RENAME Student TO Stud;
The old name table was Student now new name is the Stu.
Example:
TRUNCATE TABLE Student;
Example:
DROP TABLE Student;
It will destroy the table and all data which will be recorded in it.
Example:
ALTER TABLE STUDENT
MODIFY (Address varchar2(50) NOT NULL);
ALTER TABLE STUDENT
MODIFY (Address varchar2(50) NULL);
Example:
ALTER TABLE STUDENT
ADD CONSTRAINT check_name CHECK (name = upper(name));
Note:-DELETE all the records from the CUSTOMERS table, you do not
need to use the WHERE clause.
Example:
•SELECT SAL +10 FROM EMP; SELECT SAL - 10 FROM EMP;
•SELECT SAL * 10 FROM EMP; SELECT SAL / 10 FROM EMP;
SQL statement selects all students with a Name that starts with
"a" and are at least 3 characters in length:
SELECT * FROM Student
WHERE Name LIKE ’a__%';
SQL statement selects all students with a Name that starts with
"a" and ends with "o":
SELECT * FROM Student
WHERE Name LIKE ’a%o';
SQL statement selects all students with a Name that does NOT
start with "a":
SELECT * FROM Student
WHERE Name NOT LIKE ’a%';
Example:
DELETE FROM Student
WHERE Marks = 85;
SAVEPOINT S1;
Grant succeeded.