Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Relational algebra
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Example ==== {{col-begin|width=auto; margin:0.5em auto}} {{col-break}} {| class="wikitable" |+ ''Completed'' |- ! Student !! Task |- | Fred || Database1 |- | Fred || Database2 |- | Fred || Compiler1 |- | Eugene || Database1 |- | Eugene || Compiler1 |- | Sarah || Database1 |- | Sarah || Database2 |} {{col-break|gap=2em}} {| class="wikitable" |+ ''DBProject'' |- ! Task |- | Database1 |- | Database2 |} {{col-break|gap=2em}} {| class="wikitable" |+ ''Completed'' Γ· ''DBProject'' |- ! Student |- | Fred |- | Sarah |} {{col-end}}If ''DBProject'' contains all the tasks of the Database project, then the result of the division above contains exactly the students who have completed both of the tasks in the Database project. More formally the semantics of the division is defined as follows:{{NumBlk|:| {{math|''R'' Γ· ''S'' {{=}} { ''t''[''a''<sub>1</sub>,...,''a''<sub>''n''</sub>] : ''t'' β ''R'' β§ β''s'' β ''S'' ( (''t''[''a''<sub>1</sub>,...,''a''<sub>''n''</sub>] βͺ ''s'') β ''R'') } }} |{{EquationRef|6}}}}where {''a''<sub>1</sub>,...,''a''<sub>''n''</sub>} is the set of attribute names unique to ''R'' and ''t''[''a''<sub>1</sub>,...,''a''<sub>''n''</sub>] is the restriction of ''t'' to this set. It is usually required that the attribute names in the header of ''S'' are a subset of those of ''R'' because otherwise the result of the operation will always be empty. The simulation of the division with the basic operations is as follows. We assume that ''a''<sub>1</sub>,...,''a''<sub>''n''</sub> are the attribute names unique to ''R'' and ''b''<sub>1</sub>,...,''b''<sub>''m''</sub> are the attribute names of ''S''. In the first step we project ''R'' on its unique attribute names and construct all combinations with tuples in ''S'': : ''T'' := Ο<sub>''a''<sub>1</sub>,...,''a''<sub>''n''</sub></sub>(''R'') Γ ''S'' In the prior example, T would represent a table such that every Student (because Student is the unique key / attribute of the Completed table) is combined with every given Task. So Eugene, for instance, would have two rows, Eugene β Database1 and Eugene β Database2 in T. :: EG: First, let's pretend that "Completed" has a third attribute called "grade". It's unwanted baggage here, so we must project it off always. In fact in this step we can drop "Task" from R as well; the multiply puts it back on. :: ''T'' := Ο<sub>Student</sub>(''R'') Γ ''S'' // This gives us every possible desired combination, including those that don't actually exist in R, and excluding others (eg Fred | compiler1, which is not a desired combination) {{col-begin|width=auto; margin:0.5em auto}} {{col-break|gap=5em}} {| class="wikitable" |+ ''T'' |- ! Student !! Task |- | Fred || Database1 |- | Fred || Database2 |- | Eugene || Database1 |- | Eugene || Database2 |- | Sarah || Database1 |- | Sarah || Database2 |} {{col-end}} In the next step we subtract ''R'' from ''T'' [[relation (database)|relation]]: : ''U'' := ''T'' − ''R'' In ''U'' we have the possible combinations that "could have" been in ''R'', but weren't. :: EG: Again with projections β ''T'' and ''R'' need to have identical attribute names/headers. :: ''U'' := ''T'' − Ο<sub>Student,Task</sub>(''R'') // This gives us a "what's missing" list. {{col-begin|width=auto; margin:0.5em auto}} {{col-break|gap=5em}} {| class="wikitable" |+ ''T'' |- ! Student !! Task |- | Fred || Database1 |- | Fred || Database2 |- | Eugene || Database1 |- | Eugene || Database2 |- | Sarah || Database1 |- | Sarah || Database2 |} {{col-break|gap=2em}} {| class="wikitable" |+ ''R'' a.k.a. ''Completed'' |- ! Student !! Task |- | Fred || Database1 |- | Fred || Database2 |- | Fred || Compiler1 |- | Eugene || Database1 |- | Eugene || Compiler1 |- | Sarah || Database1 |- | Sarah || Database2 |} {{col-break|gap=2em}} {| class="wikitable" |+ ''U'' |+ aka |+ ''T'' − ''R'' |+ aka |+ ''what's missing'' |- ! Student !! Task |- | Eugene || Database2 |} {{col-end}} So if we now take the projection on the attribute names unique to ''R'' then we have the restrictions of the tuples in ''R'' for which not all combinations with tuples in ''S'' were present in ''R'': : ''V'' := Ο<sub>''a''<sub>1</sub>,...,''a''<sub>''n''</sub></sub>(''U'') :: EG: Project ''U'' down to just the attribute(s) in question (Student) :: ''V'' := Ο<sub>Student</sub>(''U'') {{col-begin|width=auto; margin:0.5em auto}} {{col-break|gap=5em}} {| class="wikitable" |+ ''V'' |- ! Student |- | Eugene |} {{col-end}} So what remains to be done is take the projection of ''R'' on its unique attribute names and subtract those in ''V'': : ''W'' := Ο<sub>''a''<sub>1</sub>,...,''a''<sub>''n''</sub></sub>(''R'') − ''V'' :: EG: ''W'' := Ο<sub>Student</sub>(''R'') − ''V''. {{col-begin|width=auto; margin:0.5em auto}} {{col-break|gap=5em}} {| class="wikitable" |+ Ο<sub>Student</sub>(''R'') |- ! Student |- | Fred |- | Eugene |- | Sarah |} {{col-break|gap=2em}} {| class="wikitable" |+ ''V'' |- ! Student |- | Eugene |} {{col-break|gap=2em}} {| class="wikitable" |+ ''W'' |+ aka |+ {{math|(Ο<sub>Student</sub>(''R'') − ''V'')}} |+ aka |+ desired result |- ! Student |- | Fred |- | Sarah |} {{col-end}}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Relational algebra
(section)
Add topic