Вы находитесь на странице: 1из 2

ANS 1(a) Natural join ()

Natural joins ( ) is a binary operator that is written as (R S) where R and S are relations.[1] The result of the natural join is the set of all combinations of tuples in R and S that are equal on their

common attribute names. For an example consider the tables Employee and Dept and their natural join:

Employee

Dept Employee Dept

Name EmpId DeptName

DeptName Manager Name EmpId DeptName Manager

Harry

3415

Finance

Finance

George Harry 3415 Finance George

Sally

2241

Sales

Sales

Harriet Sally 2241 Sales Harriet

George 3401

Finance

Production Charles George 3401 Finance George

Harriet 2202

Sales Harriet 2202 Sales Harriet

This can also be used to define composition of relations. In category theory, the join is precisely the fiber product.

The natural join is arguably one of the most important operators since it is the relational counterpart of logical AND. Note carefully that if the same variable appears in each of two predicates that are connected by AND, then that variable stands for the same thing and both appearances must always be substituted by the same value. In particular, natural join allows the combination of relations that are associated by a foreign key. For example, in the above example a foreign key probably holds from Employee.DeptName to Dept.DeptName and then the natural join of Employee and Deptcombines all employees with their departments. Note that this works because the foreign key holds between attributes with the same name. If this is not the case such as in the foreign key fromDept.manager to Employee.Name then we have to rename these columns before we take the natural join. Such a join is sometimes also referred to as an equijoin (see -join).

More formally the semantics of the natural join is defined as follows:

where Fun is a predicate that is true for a relation r if and only if r is a function. It is usually required that R and S must have at least one common attribute, but if this constraint is omitted, and R and Shave no common attribute

CARTESIAN PRODUCT

The Cartesian Product is also an operator which works on two sets. It is sometimes called the CROSS PRODUCT or CROSS JOIN. It combines the tuples of one relation with all the tuples of the other relation.

CARTESIAN PRODUCT example

Figure : CARTESIAN PRODUCT

JOIN Operator

JOIN is used to combine related tuples from two relations: In its simplest form the JOIN operator is just the cross product of the two relations. As the join becomes more complex, tuples are removed within the cross product to make the result of the join more meaningful. JOIN allows you to evaluate a join condition between the attributes of the relations on which the join is undertaken. The notation used is
R JOINjoin
condition

Definition (Cartesian product): The set of all ordered pairs <a, b>, where a is an element of A and b is an element of B, is called the Cartesian product of A and B and is denoted by A Example 1: Let A = {1, 2, 3} and B = {a, b}. Then A B = {<1, a>, <1, b>, <2, a>, <2, b>, <3, a>, <3, b>} . B.

Ans 1 (B)
A database model is a theory or specification describing how a database is structured and used.

Вам также может понравиться