Professional Documents
Culture Documents
when we want to join more than one taqble to establish relationship between
them then it is called as joining .
if we want to join n number of tables then we must require n-1 number of codition .
there are 5 types of joining available in sql.
1.equal /inner/natural join
: when we want to join more than one tables having a common fields in all the
tavles then it is called as equal join .
there are 5 processes to solve equal join.
a.using theta process:
select emp ,eneame,dept,,dname from emp ,dept where
emp.deptno=dept.depno;
b.using ansi process:
select e.ename,d.dname from emp,dept d where e.deptno=d.deptno;
c.using natural join:
5.self join:
SET OPERATION :
it is divided in to catagories:
1.union
It is used to join the data two tables.
select deptno from emp union select deptno from dept;
2.intersection
It is used to delete the duplicate data from a table.
select deptno from emp intersect select deptno from dept;
3.minus
It is used to delete the duplicate data from a table where there is common data
present inside it.
select deptno from emp minus select deptno from dept;
4.union all
It is used to join the data from both the tables.
select deptno from emp union all select deptno from dept;
constraint:
are the rules applied to the database table to make the data more than accurate.
when there are 5 types of constraint available in sql.
1.unique key constraint
A NOT NULL constraint is a rule that prevents null values from being entered into
one or more columns within a table.
A primary key constraint is a column or combination of columns that has the same
properties as a unique constraint. You can use a primary key and foreign key
constraints to define relationships between tables.
A table check constraint (also called a check constraint) sets restrictions on data
that is added to a specific table. For example, you can use a table check
constraint whenever salary data is added or updated in a table that contains
personnel information. For such operations, the table check constraint can ensure
that the salary level for an employee is at least $20 000.