Relational Operation Intersection
The Intersection (Figure 1.21) in mathematics involves creating a set that includes elements of both intersecting source sets. This feature gives huge opportunities in databases,
when it is necessary to limit the selectable data, which is the most frequently used action when working with data.
Fig. 1.21. The operation of intersection of sets (n) |
Implementing the Intersection in Relational Algebra, consider relations which, as in the previous case (Operation "Unification"), must have the property of the identity of the relationship, i.e. have similar structures and data types but the attributes that are available in the relationship (Figure 1.22).
Fig. 1.22. Sample implementation of the Intersection (n) |
As you can see in the figure above, both relationships have the same structures (set of attributes). As a result of the Intersection there was only one tuple - having the same data in both initial relations. Other tuples of relations did not fall into the resulting ratio.
This feature of the Intersection allows to select data from different tables when working with data in databases, taking into account only overlapping (identical) stored information and limiting the results of the received data, which allows receiving only such information that corresponds to the information need of the user.
As well as many actions on sets in mathematics, the operation "Intersection" has the property of commutativity, which is expressed in the absence of an explicit orientation of the action. This means that by performing operations & L; crosses B and B intersects L we get absolutely identical results.
Relational Operation & "Difference
Unlike the Intersection and Pooling Operation Difference does not possess the commutativity property and is represented by a directed action (Figure 1.23). The same effect in mathematics is possessed by the effect of the difference (for example, "2-5 and" 5-2 are not identical operation, since they return different results). The same applies to operations on sets.
Fig. 1.23. The operation of the difference of sets () |
Similar to the Pooling and Intersection The operation in question requires that the original relations have identical structures and data types. Since the operation involves a complete comparison of the data from the source relationships for all attributes, the appearance of an attribute in one of the relations not represented in another relation will not allow such a comparison to be made, which means it will not allow the result of the operation to be obtained (Figure 1.24).
Fig. 1.24. Example of the implementation of the operation Difference () |
As it is obvious from the example, if we perform an operation in the direction of the left relation (tuples for employees: Ivanov Ivan Ivanovich and Petrov Petr Petrovich) to the right relation (tuples for employees: Sidor Sidor Sidorovich and Peter Petrov Petrovich), we get the result, where there will be only such a cortege that is not represented in the right relation (a cortege for the employee: Ivanov Ivan Ivanovich).
The process of performing the Difference is carried out as follows.
1. Tuples of the first relation are selected.
2. Tuples of the second relation are selected.
3. In the first respect, for each tuple, the presence of the same tuple in the second relation is checked:
a) if in the second respect the required tuple is not represented, then it is represented as a result;
b) if the desired tuple exists in the second relation, it is not included in the result of the operation.
As a result, only the unique tuples from the first relationship remain. And what happens to the unique tuples of the second relationship? - Nothing. These tuples do not participate in the Difference operation, which is due to the lack of commutativity in the Difference operation. Tuples of the second relation for this operation are necessary only for the purpose of verifying the existence of a tuple that is identical with respect to the first relation.
Relational operation Cartesian product
Operation Cartesian product (Figure 1.25) is not very often used in databases, but it is very useful when it is necessary to get the whole set of any intersections of elements of initial sets. In mathematics, this operation involves obtaining a new set consisting of all possible ones, where the first element is taken from the first set, and the second from the second set.
Unlike all previous operations, this operation does not require the identity of the original relationship structures. But the initial relationship must necessarily be imposed one limitation - the headers of both relations must contain unique attributes. This condition is due to the fact that in the header of the resulting relation all the attributes from the headers of the original relations will be presented, and if at least one identical attribute exists in their headers, then this is a hi to the appearance of two identical attributes in the resulting relation, which is inadvisable because it is impossible to uniquely determine a tuple with the appropriate name.
Fig. 1.25. Example of the implementation of the operation Cartesian product |
As is clear from the example, the relations "Employee" are taken as the initial relations. and Job & quot ;. Both relations are essentially original handbooks with unique tuples. By the condition of the operation performed, it is necessary to carry out the Cartesian product over these relations, which led to the appearance of a new relation that received all the attributes of the original relations, and the tuples were combined but to all the rules of the operation being performed, where all the tuples of the first relation were taken and to each obtained cortege was put in match each tuple from the second relationship.
When creating a database in the right view, developers do not often need to perform this operation. However, such a need may arise. For example, there are lists of students (Table 1.4) of a certain training group who must perform a number of works (Table 1.5), for which a condition is determined that before the moment of their fulfillment, all students for each work are given unsatisfactory evaluation regardless of the fact of doing the work. Thus, it turns out that by the time the work starts, there must already be records in the database that will link each student to each job.
Table 1.4
Example of the first attitude "Student" |
No. |
Full name of the student |
1 |
Arsen Gurenovich Karapetyan |
2 |
Arina Ivanovna Malyshkina |
3 |
Nolshov Ivan Petrovich |
Table 1.5
The
Example of the second relationship "Jobs" |
Activity type |
Title of work |
Test work |
Mathematical Logic |
Workshop |
Propositional calculus |
Workshop |
Logical Programs and the Basics |
The result of the Cartesian work there will be a new ratio, shown in Table. 1.6.
Table 1.6 Example of the resulting relationship "Student Works" |
No. |
Full name of the student |
Activity type |
Title of work |
1 |
Arsen Gurenovich Karapetyan |
Control Work |
Mathematical Logic |
2 |
Arina Ivanovna Malyshkina |
Control Work |
Mathematical Logic |
3 |
Ivan Petrovich Polynov |
Control Work |
Mathematical Logic |
thematic pictures
Also We Can Offer!
Essay Writing
[...]
- Argumentative essay
- Best college essays
- Buy custom essays online
- Buy essay online
- Cheap essay
- Cheap essay writing service
- Cheap writing service
- College essay
- College essay introduction
- College essay writing service
- Compare and contrast essay
- Custom essay
- Custom essay writing service
- Custom essays writing services
- Death penalty essay
- Do my essay
- Essay about love
- Essay about yourself
- Essay help
- Essay writing help
- Essay writing service reviews
- Essays online
- Fast food essay
- George orwell essays
- Human rights essay
- Narrative essay
- Pay to write essay
- Personal essay for college
- Personal narrative essay
- Persuasive writing
- Write my essay
- Write my essay for me cheap
- Writing a scholarship essay
Case Study
[...]
Citation Style
[...]
Additional Services
[...]
CV
[...]
Assignment Help
[...]
Admission Services
[...]
Custom Paper
[...]