Table of Contents

This module converts a relational algebra query into python code, which can be executed using the relational module.

**IMPORTANT: It is necessary to use unicode strings instead of normal ones.**

Use:

import parser ... ... ... code=parser.parse(expression) result=eval(code,dict)

It has 2 class of operators:

Symbol | Name | Example |
---|---|---|

* | product | A * B |

- | difference | A - B |

ᑌ | union | A ᑌ B |

ᑎ | intersection | A ᑎ B |

ᐅᐊ | join | A ᐅᐊ B |

ᐅLEFTᐊ | left outer join | A ᐅLEFTᐊ B |

ᐅRIGHTᐊ | right outer join | A ᐅRIGHTᐊ B |

ᐅFULLᐊ | full outer join | A ᐅFULLᐊ B |

Syntax for those operators is: `relation operator relation`

Symbol | Name | Example | Note |
---|---|---|---|

σ | selection | σ id==index or rank>3 (A) | Expression must be written in python |

π | projection | π name,age (A) | Spaces in attributes will be ignored |

ρ | rename | ρ index➡id,age➡old (A) | Spaces in the parameters will be ignored |

Syntax for those is: `operator parameters (relation)`

Since `a*b`

is a relation itself, you can parse `π a,b (a*b)`

; and since `π a,b (A)`

is a relation, you can parse `π a,b (A) ᑌ B`

.

You can use parenthesis to change priority: `a ᐅᐊ (q ᑌ d)`

σage > 25 and rank == weight(A)

Q ᐅᐊ π a,b(A) ᐅᐊ B

ρid➡i,name➡n(A) - π a,b(π a,b(A)) ᑎ σage > 25 or rank = weight(A)

π a,b(π a,b(A))

ρid➡i,name➡n(π a,b(A))

A ᐅᐊ B

Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.2