|
||||||||||
| PREV NEXT | FRAMES NO FRAMES |
See:
Description
| Validator Packages | |
|---|---|
| org.hibernate.validator | Bootstrap classes HibernateValidator and HibernateValidatorConfiguration which uniquely identify Hibernate Validator and allow to configure it. |
| org.hibernate.validator.cfg | Entry point for the programmatic constraint definition API. |
| org.hibernate.validator.cfg.context | Contains facet and creational context interfaces forming the API for programmatic constraint definition. |
| org.hibernate.validator.cfg.defs | Constraint definition classes for programmatic constraint definition API. |
| org.hibernate.validator.constraints | Hibernate Validator specific constraints. |
| org.hibernate.validator.constraints.br | Hibernate Validator Brazilian constraints. |
| org.hibernate.validator.group | This package provides support for dynamic default group sequence definition. |
| org.hibernate.validator.internal.cfg | Implementation parts of the API for programmatic constraint definition. |
| org.hibernate.validator.internal.cfg.context | Creational context implementations of the API for programmatic constraint definition. |
| org.hibernate.validator.internal.constraintvalidators | Implementations of the Bean Validation built-in as well as Hibernate Validator specific constraints. |
| org.hibernate.validator.internal.engine | Implementations for the core interfaces of JSR-303. |
| org.hibernate.validator.internal.engine.constraintvalidation | Classes dealing with the representation of constraints and the management/instantitation of constraint validators. |
| org.hibernate.validator.internal.engine.groups | Helper classes for the processing of groups. |
| org.hibernate.validator.internal.engine.messageinterpolation | Helper classes for message interpolation. |
| org.hibernate.validator.internal.engine.messageinterpolation.el | Helper classes for setting up the Expression Language context for message interpolation. |
| org.hibernate.validator.internal.engine.path | Classes related to the Path.Node API. |
| org.hibernate.validator.internal.engine.resolver | Various implementations of the TraversableResolver interface. |
| org.hibernate.validator.internal.metadata | Implementations of the Bean Validation metadata interfaces as well as Hibernate Validator specific meta data classes. |
| org.hibernate.validator.internal.metadata.aggregated | The classes in this package contain the aggregated meta data needed for an actual validation. |
| org.hibernate.validator.internal.metadata.aggregated.rule | Contains MethodConfigurationRule and its subclasses used to validate the correctness of method constraints on overridden/implemented methods in inheritance hierarchies. |
| org.hibernate.validator.internal.metadata.core | Core classes of the internal model used for representing constraints and related metadata. |
| org.hibernate.validator.internal.metadata.descriptor | Implementation of the Bean Validation meta data API. |
| org.hibernate.validator.internal.metadata.facets | Contains the facet interfaces implemented by the aggregated meta data model types, allowing for a unified validation routine for all kinds of validation (bean, parameter and return value validation). |
| org.hibernate.validator.internal.metadata.location | Contains types for the representation of constraint locations. |
| org.hibernate.validator.internal.metadata.provider | Abstraction of the meta data sources - annotation, xml, programmatic |
| org.hibernate.validator.internal.metadata.raw | The raw metadata is a reflection of all configured constraints including constraints defined via multiple configuration sources. |
| org.hibernate.validator.internal.util | Independent helper classes. |
| org.hibernate.validator.internal.util.annotationfactory | Annotation proxy helper. |
| org.hibernate.validator.internal.util.classhierarchy | Contains classes for working with the elements of a class hierarchy. |
| org.hibernate.validator.internal.util.logging | Logging classes. |
| org.hibernate.validator.internal.util.privilegedactions | Implementations of PrivilegedAction in order to execute reflection operations in a security manager. |
| org.hibernate.validator.internal.util.scriptengine | Classes related to the evaluation of script with ScriptEngine (JSR-223). |
| org.hibernate.validator.internal.xml | Classes for parsing of Bean Validation XML configuration files. |
| org.hibernate.validator.messageinterpolation | Implementations of the MessageInterpolator interface in particular ResourceBundleMessageInterpolator which can be used by custom implementations of the interface for delegation. |
| org.hibernate.validator.resourceloading | ResourceBundleLocator interface and its various implementations. |
| org.hibernate.validator.spi.group | This package provides support for dynamic default group sequence definition. |
| org.hibernate.validator.spi.resourceloading | ResourceBundleLocator interface. |
| Validator Portable Extension Packages | |
|---|---|
| org.hibernate.validator.cdi | Public types dealing with the integration of Hibernate Validator and CDI ("Contexts and Dependency Injection for JavaTM", JSR 346). |
| org.hibernate.validator.internal.cdi | Classes for enabling Bean Validation CDI integration. |
| org.hibernate.validator.internal.cdi.interceptor | Classes for enabling Bean Validation method validation via a CDI interceptor. |
| Annotation Processor Packages | |
|---|---|
| org.hibernate.validator.ap | This package contains the main class of Hibernate Validator annotation processor. |
| org.hibernate.validator.ap.checks | This package contains check implementations used by the annotation processor to verify constraint declarations. |
| org.hibernate.validator.ap.util | This package contains helper classes. |
This is the Hibernate Validator API documentation. Hibernate Validator is the reference implementation of Bean Validation 1.1 - JSR-349
All classes fall into three categories:
|
||||||||||
| PREV NEXT | FRAMES NO FRAMES |


The Utensils that are going to last long
Laxmi Utensil Store Indra Chowk Main Market Hanumangarh Town
Phone no. 7888378XXX Email<EMAIL_ADDRESS>Visit our social account


We’ve recorded your pin drop!
Does someone else in your office have a guess?*
Shop VALO Guess again
*Each office can submit up to three entries. One entry per person.


Hi, am a fullstack developer based in Nairobi kenya. i am a critical thinker,problem solver and a coding junkie. when am afkb (away from the key board) i am a family man, a runner, and a swimmer.
Projects
click images to view project details
GameTime
GameTime
Game time is a web application that provides users with updates from international soccer leagues.this was implemented with python/django, postgresqldatabase,GoogleApi and scrapy and on the front-end Javascript, Html, Jquery, Ajax and Bootstrap was used
GoodFood helps users cook there favourite food providing them with varieties of recipes. this website showcases my front-end skills. its beutifully designed and styled with Html/ Bootstrap, JavaScript, JQuery and custom Css


Hero gran-of-seven runs into raging bushfire to rescue badly burned koala
The koala suffers burns to his feet, nose, underarms and chest but is luckily being treated after gran Toni Doherty rushed him to a hospital in Port Macquarie, Australia
by Tiffany LoA hero grandmother has braved the raging fire to rescue a badly burned koala .
Toni Doherty was driving past Port Macquarie in New South Wales, Australia, and spotted the animal crawling through the woods in the bushfire.
She told 9 News : "He just went straight into the flames and I just jumped out of the car and went straight to him."
Mobile phone footage shows Toni grabbing the koala off a tree and quickly pouring water over the injured animal.
The koala can be heard wailing in pain when Toni tries to cool it with water.
She then bundles the animal with her shirt and rushes to Port Macquarie Koala Hotel where he is being closely monitored by staff.
Toni named the koala Lewis, after one of her seven grandchildren.
The 14-year-old koala suffered serious burns as hospital staff said its health 'hangs in the balance'.
Cheyne Flanagan, who took care of the koala at the hospital said: "He is probably 50-50 at this stage.
"His feet are completely burnt and he has burns to his chest and stomach. His nose is burned.
"He has been bandaged and given antibiotics but will take a lot of looking after, if he pulls through."
The gran-of-seven reunited with Lewis yesterday to check on his recovery.
'Lewis' is being given lots of fluid and has been munching on eucalyptus leaves.
The devastating fire has claimed one-third of koala population in the Port Macquarie region, according to reports.
The hospital is also taking care of four other koalas that were injured in the bushfire.
They have set up a fundraising page to call for animal lovers to help rebuild the koalas' habitat.


--- title: Analyzing Bangalore - Population (Part 2 - Smoothed Line Graph) author: Shyam Valsan date: '2017-11-27' slug: analyzing-bangalore-population-smoothed-line-graph categories: - blog - data exploration - data science - R tags: - Bangalore - bengaluru - population - R - line graph - growth rate ---
This is part 2 of the Analyzing Bangalore - Population series. You might find Part 1 and Part 3 interesting as well.
This is a simple smoothed line chart of population growth rate over time, and yet it is very revealing.
library(ggplot2)
blr_growth_rate <- read.csv("BangaloreGrowthRate.csv")
ggplot(blr_growth_rate,aes(x = Time,y = GrowthRate )) +
geom_point(aes(colour = GrowthRate)) +
scale_colour_gradient2(low = "blue", mid = "green" , high = "red", midpoint = 3.5) +
geom_smooth(colour = "blue",size = 0.9) +
scale_y_continuous(limits = c(1,7), breaks = seq(1,7,1)) +
scale_x_continuous(limits = c(1955,2030), breaks = seq(1960,2030,10)) +
ggtitle ("Average Annual Rate of Change of Population in Bangalore") +
xlab("Year") + ylab ("Average Growth Rate %")
## `geom_smooth()` using method = 'loess'
Key takeaways
Let’s examine the two periods of rapid growth in population which Bangalore has experienced in the last 70 years.
Data sources
United Nations Top 30 Urban Agglomerations - Population and Growth Rate
Suggestions and corrections are always welcome, please use the comments section.


Word Frequencies UNDP
SDG 8: Decent Work and Economic Growth
See how other words compare to the top 20 words in SDG 8
Add
default


Oppia’s lesson creation team is responsible for creating a set of highly effective and enjoyable lessons that students around the world can use for free. The team follows a tested process to generate effective lessons that appeal to students from all backgrounds.
Our goal is to not only teach students in an easily digestible way, but also encourage a positive attitude towards learning. Currently, we're focusing on basic mathematics, but intend to expand to other subjects in the future.
Oppia’s lesson creation team is responsible for creating a set of highly effective and enjoyable lessons that students around the world can use for free. The team follows a tested process to generate effective lessons that appeal to students from all backgrounds.
Our goal is to not only teach students in an easily digestible way, but also encourage a positive attitude towards learning. Currently, we're focusing on basic mathematics, but intend to expand to other subjects in the future.


Welcome to the Veltrix DashBoard
| (#)Id | Name | Date | Amount | Status | |
|---|---|---|---|---|---|
| #14256 | Philip Smead | 15/1/2018 | $94 | Delivered |
Edit |
| #14258 | Brent Shilpey | 16/1/2019 | $112 | Pending |
Edit |
| #14259 | Robert Sitton | 17/1/2019 | $116 | Delivered |
Edit |
| #14260 | Alberto Jackson | 18/1/2019 | $109 | Cancel |
Edit |
| #14261 | David Sanchez | 19/1/2019 | $120 | Delivered |
Edit |


public static final class R.string
extends java.lang.Object
| Constructor and Description |
|---|
R.string() |
public static final int abc_action_bar_home_description
public static final int abc_action_bar_home_description_format
public static final int abc_action_bar_home_subtitle_description_format
public static final int abc_action_bar_up_description
public static final int abc_action_menu_overflow_description
public static final int abc_action_mode_done
public static final int abc_activity_chooser_view_see_all
public static final int abc_activitychooserview_choose_application
public static final int abc_capital_off
public static final int abc_capital_on
public static final int abc_search_hint
public static final int abc_searchview_description_clear
public static final int abc_searchview_description_query
public static final int abc_searchview_description_search
public static final int abc_searchview_description_submit
public static final int abc_searchview_description_voice
public static final int abc_shareactionprovider_share_with
public static final int abc_shareactionprovider_share_with_application
public static final int abc_toolbar_collapse_description
public static final int addNewItem
public static final int app_name
public static final int appbar_scrolling_view_behavior
public static final int auth_google_play_services_client_facebook_display_name
public static final int auth_google_play_services_client_google_display_name
public static final int character_counter_pattern
public static final int common_google_play_services_api_unavailable_text
public static final int common_google_play_services_enable_button
public static final int common_google_play_services_enable_text
public static final int common_google_play_services_enable_title
public static final int common_google_play_services_install_button
public static final int common_google_play_services_install_text_phone
public static final int common_google_play_services_install_text_tablet
public static final int common_google_play_services_install_title
public static final int common_google_play_services_invalid_account_text
public static final int common_google_play_services_invalid_account_title
public static final int common_google_play_services_network_error_text
public static final int common_google_play_services_network_error_title
public static final int common_google_play_services_notification_ticker
public static final int common_google_play_services_restricted_profile_text
public static final int common_google_play_services_restricted_profile_title
public static final int common_google_play_services_sign_in_failed_text
public static final int common_google_play_services_sign_in_failed_title
public static final int common_google_play_services_unknown_issue
public static final int common_google_play_services_unsupported_text
public static final int common_google_play_services_unsupported_title
public static final int common_google_play_services_update_button
public static final int common_google_play_services_update_text
public static final int common_google_play_services_update_title
public static final int common_google_play_services_updating_text
public static final int common_google_play_services_updating_title
public static final int common_google_play_services_wear_update_text
public static final int common_open_on_phone
public static final int common_signin_button_text
public static final int common_signin_button_text_long
public static final int dialogAccept
public static final int dialogCancel
public static final int dialogDecline
public static final int dialogNo
public static final int dialogNoBid
public static final int dialogYes
public static final int dialogYesBid
public static final int email
public static final int filter
public static final int login_register
public static final int maxPlayers
public static final int message
public static final int messageHint
public static final int minAge
public static final int minPlayers
public static final int minTimeReq
public static final int myItems
public static final int name
public static final int password
public static final int phone
public static final int platform
public static final int send
public static final int status_bar_notification_info_overflow
public static final int title_activity_view_item
public static final int userProfile
public static final int username


Jehanne Jackson Notes
How does the World Wide Web work?
When you sit infront of your computer you get on the browser e.g. Chrome,Internet Explorer etc
.
The browser sends a signal requesting the files via the internet to the servers.
The servers send back the requested files to the computer. This is a basic outline on how the World Wide Web work.
Topic:HTML
HTML(Hypertext Markup Language)
Main type of document found on the web.
There are other types of docs like pdf,images,videos etc.
HTML Markup
This is how the HTML looks. Example< b > is to make a script bold,< em > is to make it italics.
HTML Attributes
This is used to place links on HTML created pages.
< a href = "www.yahoo.com" > HEY < /a>
a-anchor, href-attribute name, value-www.yahoo.com,link name-HEY
HTML Images
This is used when placing an image. There is no closing tag,
because there is no content. With no content and no closing tag this is
considered a void tag
for this element.
< img src = "url" alt= "text" >
...alt="text"> is required.
WHITESPACE
This is the space between lines.
This is created by < br > line break, this is a void, there is no content no closing tag.
Then there is < p> content < /p>. < paragraph> when used it creates a space between lines.
INLINE AND BLOCK
Inline tags do not create the imaginery box space between both lines.
While Block tags create imaginery box space between both lines.
Inline
< a >
< span >
< br >
< img >
< strong >
Block
< div >
< p >
< form >


| Author: | Greg Gaughan |
|---|---|
| Copyright: | Copyright (C) 2007 Greg Gaughan |
| Licence: | GPL (see Licence.txt for details) |
| Contact: |<EMAIL_ADDRESS>|
| Date: | 22/05/2007 |
Contents
Inspired by Date and Darwen's Databases, Types and the Relational Model (The Third Manifesto), we're putting forward an implementation of a truly relational language using Python. We will address two problems:
- The impedance mismatch between programming languages and databases
- The weakness and syntactic awkwardness of SQL
Most of today's programs handle data in one way or another and often this data is stored in some kind of relational database. To read and modify this data, a program must bridge the gap between its representation and the one used by the dialect of SQL that the database provides. This bridge typically comprises a database API that sends queries as text strings, often accompanied by some kind of table-to-object mapper that has to coerce data and relationships in both directions, usually with elaborate layers of abstraction in an effort to keep the two sides loosely coupled.
"Yet by obscuring the true data source these solutions end up throwing away the most compelling feature of relational databases; the ability for the data to be queried."
—Microsoft, DLinq .NET Language-Integrated Query for Relational Data, May 2006
This approach not only adds complexity and increases the need for data transformations but, most importantly, it destroys the significant advantages provided by the relational model of data. The relational model is built upon predicate logic which brings the power of formal reasoning to data: it is the only sound foundation available.
A number of approaches and frameworks have been proposed to span the gap between the two systems; most never question why there are two systems in the first place.
Microsoft's forthcoming LINQ to SQL (formerly DLinq) is a major attempt to bring SQL closer into the program than before, but will still keep the database sub-language and all that it entails.
"It is no wonder that applications expected to bridge this gap are difficult to build and maintain. It would certainly simplify the equation to get rid of one side or the other. Yet relational databases provide critical infrastructure for long-term storage and query processing, and modern programming languages are indispensable for agile development and rich computation."
—Microsoft, DLinq .NET Language-Integrated Query for Relational Data, May 2006
The solution to the problem is not to get rid of one side or the other, nor to have one side overlap the other, but to merge the two sides into one: supersede SQL (the COBOL of database languages) with a true relational programming language, one that is computationally complete, and then the gap disappears. Our solution uses one of the most effective, expressive and readable languages available, Python, and extends it with relations and a sound relational algebra.
Since its inception in 1969 by E. F. Codd, the relational model has been the foundation for nearly all databases. It replaced earlier network and hierarchical ad-hoc approaches to data storage by being as simple as it needed to be, but no simpler. It was so powerful it allowed users to ask for what they wanted to find, rather than specify how they might find it.
Over the decades, SQL has become the de-facto language for relational databases, but SQL misses many of the benefits of relational technology. In recent years, partly due to SQL's weaknesses and partly due to minimalistic and stagnant implementations, the database has become merely a storage engine fronted by layers of drivers, mappers, hierarchical markups and frameworks which make flexible querying both complex and distant from the application code.
Having implemented a comprehensive, standards-compliant SQL server, ThinkSQL, we did some further research into the history of SQL's dominance in the marketplace and its quirky syntax. We found a far superior alternative in the form of D [1], a generic name for any relational language that conforms to The Third Manifesto. We’ve implemented such a language, Dee, as an extension to Python.
The relational algebra and most of the ideas underlying Dee come from Date and Darwen's Databases, Types and the Relational Model (The Third Manifesto). An introduction into the ideas behind it can be found in Databases in Depth and many related links and reference materials are on The Third Manifesto website.
The current version of Dee is an initial release to gain feedback regarding the approach. We chose Python because its interpreted style, dynamic typing and built-in sets and dictionaries make it ideal for interacting with data; plus any language that allows you to do the following sorts of things has got to be good:
>>> x, y = 45, 90
>>> print x, y
45 90
>>> x, y = y, x #swapping values without the usual temporary variable!
>>> print x, y
90 45
>>> 70 < x < 120
True
See Why Use Python? for more information on the advantages of the language. A guide to the Python language can be found in An Introduction to Python. We do assume you are familiar with Python in what follows.
The current release is an initial proposal, intended to encourage feedback. We have many ideas for future versions to make it more deployable. See the Future Work section below for more details.
To start using Dee from within the Python interpreter or from a Python program, first import the module. (For demonstrating we import everything but it's recommended that you only import the features you need.)
>>> from Dee import *
A Tuple is a set of attribute/value pairs. A Tuple can be represented by a Python dictionary, e.g.
>>> print {"StudentId":'S1', "Name":'Anne'}
{'StudentId': 'S1', 'Name': 'Anne'}
and the attributes and values can be extracted using the standard Python syntax, e.g.
>>> t1 = {"StudentId":'S1', "Name":'Anne'}
>>> t1["StudentId"]
'S1'
>>> "Name" in t1
True
>>> t1.keys()
['StudentId', 'Name']
A more powerful way is to use the Tuple class which allows a slightly simpler syntax for denoting attribute values. To specify a Tuple:
>>> t1 = Tuple(StudentId='S1', Name='Anne')
and then the attributes values can be extracted in the same way as the Python dictionary but also using the dot notation without the quotes, e.g.
>>> t1["Name"]
'Anne'
>>> t1.Name
'Anne'
The Tuple class also provides a number of useful methods, such as project and remove, for manipulating relational tuples.
Attribute values are dynamically typed in the usual Python way and they must be of the same type for every tuple in a given relation. Currently, the types can be anything that can be pickled.
A Relation comprises a heading and a body. The heading is a set of attribute name/type pairs. The body is a set of tuples. Each tuple in the body comprises a value for every attribute in the heading. To specify a relation literal, pass the heading as a list of attribute names followed by the body as a list of tuple literals, e.g.:
>>> print Relation(["StudentId", "Name"],
... [{"StudentId":'S1', "Name":'Anne'},
... {"StudentId":'S2', "Name":'Boris'},
... {"StudentId":'S3', "Name":'Cindy'},
... {"StudentId":'S4', "Name":'Devinder'},
... {"StudentId":'S5', "Name":'Boris'},
... ])
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
Note:
Also, we will try to use the term relation variable when we mean a variable that refers to a Relation, and just relation (or relation value) to mean the value of the relation. This is an important distinction. The value of a relation never changes, just like the value 5 never changes.
To assign a relation value to a relation variable, use the standard Python syntax, e.g.
>>> IS_CALLED = Relation(["StudentId", "Name"],
... [{"StudentId":'S1', "Name":'Anne'},
... {"StudentId":'S2', "Name":'Boris'},
... {"StudentId":'S3', "Name":'Cindy'},
... {"StudentId":'S4', "Name":'Devinder'},
... {"StudentId":'S5', "Name":'Boris'},
... ])
An alternative way to define a relation is to use the Tuple class to define the body:
>>> IS_CALLED = Relation(["StudentId", "Name"],
... [Tuple(StudentId='S1', Name='Anne'),
... Tuple(StudentId='S2', Name='Boris'),
... Tuple(StudentId='S3', Name='Cindy'),
... Tuple(StudentId='S4', Name='Devinder'),
... Tuple(StudentId='S5', Name='Boris'),
... ])
or alteratively, a more concise option is available which relies on the order of the body attributes matching the order of the heading:
>>> IS_CALLED = Relation(["StudentId", "Name"],
... [('S1', 'Anne'),
... ('S2', 'Boris'),
... ('S3', 'Cindy'),
... ('S4', 'Devinder'),
... ('S5', 'Boris'),
... ])
(Note that Python allows an additional comma after the last item in a list, which can simplify copy/paste operations. Also a Python tuple with a single value must have a comma after the value to distinguish it from a value in parentheses, e.g. (7,) rather than (7))
There are a number of ways to display a relation:
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> print `IS_CALLED` #or just: >>> IS_CALLED
Relation(('StudentId', 'Name'),
[Tuple(StudentId='S1', Name='Anne'), Tuple(StudentId='S2', Name='Boris'), Tuple(StudentId='S3', Name='Cindy'), Tuple(StudentId='S4', Name='Devinder'), Tuple(StudentId='S5', Name='Boris')],
{'PK':(Key, None)})
Note: this literal can itself be evaluated using Python's eval() function to retrieve the relation's value, e.g.
>>> print eval(`IS_CALLED`)
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> r2=eval(`IS_CALLED`)
>>> print r2
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> print IS_CALLED.renderHTML()

StudentId	Name

S1	Anne

S2	Boris

S3	Cindy

S4	Devinder

S5	Boris

Which in a browser becomes:
StudentId Name S1 Anne S2 Boris S3 Cindy S4 Devinder S5 Boris
The heading of a relation can be retrieved via its heading method, which returns the attribute names as a Python set, e.g.
>>> print IS_CALLED.heading()
set(['StudentId', 'Name'])
Given a relation such as the one denoted by IS_CALLED above, we should take the meaning of it to be as follows:
Instead of defining the value of a relation variable once when it is assigned, we can refer to a function to provide the relation. The function can then return different values at different times. One important kind of relation variable that refers to a function for its data is a virtual (or derived) relation variable. A virtual relation variable refers to a function that returns a relational expression. All other relational variables are base relation variables. To specify a virtual relation variable we first need to define a function to provide the data by returning a relational expression. For example (ignore the relational expression syntax for now, we'll cover the details of that later):
>>> def vIS_CALLED_caps():
... return IS_CALLED.extend(['NameCaps'], lambda t: {'NameCaps': t.Name.upper()}).remove(['Name'])
Then pass the heading as a list of attribute names followed by the body as a function reference, e.g.
>>> IS_CALLED_caps = Relation(["StudentId", "NameCaps"], vIS_CALLED_caps)
>>> print IS_CALLED_caps
+-----------+----------+
| StudentId | NameCaps |
+===========+==========+
| S1 | ANNE |
| S2 | BORIS |
| S3 | CINDY |
| S4 | DEVINDER |
| S5 | BORIS |
+-----------+----------+
Such virtual relation variables' values will then vary as the underlying base relation variables vary. These virtual relation variables are called views in SQL.
An attribute value can itself be a relation. Such attributes are known as relation-valued attributes or RVAs. There are a number of relational operators (actually macros) that use such nested relations. For example, GROUP, which takes a relation and a set of attribute names together with a new attribute name and returns a relation with the set of attributes as a nested relation, 1 per unique value of the non-grouped attributes:
>>> print GROUP(IS_CALLED, ['StudentId'], 'StudentIds')
+----------+---------------+
| Name | StudentIds |
+==========+===============+
| Anne | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S1 | |
| | +-----------+ |
| Boris | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S2 | |
| | | S5 | |
| | +-----------+ |
| Cindy | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S3 | |
| | +-----------+ |
| Devinder | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S4 | |
| | +-----------+ |
+----------+---------------+
There are two interesting relations that are useful for defining some fundamental relational operators in Dee. We introduce them here.
This is the relation that has no attributes and no tuples. It plays the role of False. It is difficult to display:
>>> print DUM
+
|
+
+
>>> print DUM.renderHTML()

It is also called TABLE_DUM and FALSE.
This is the relation that has no attributes and a single tuple. It plays the role of True. It is difficult to display:
>>> print DEE
+
|
+
|
+
>>> print DEE.renderHTML()

It is also called TABLE_DEE and TRUE.
A Relation (function-based or not) can also take an extra parameter in its constructor to specify a set of constraints. This takes the form of a Python dictionary where each key gives the constraint name and each value is a pair of constraint-function, parameters. For example, to specify that the "StudentId" attribute is a candidate key for the above relation we could say:
>>> IS_CALLED = Relation(["StudentId", "Name"],
... [('S1', 'Anne'),
... ('S2', 'Boris'),
... ('S3', 'Cindy'),
... ('S4', 'Devinder'),
... ('S5', 'Boris'),
... ],
... {'PK':(Key, ["StudentId"])}
... )
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
Here, Key is a pre-defined constraint type (actually a function wrapper that creates a function) that takes a list of attributes to enforce the constraint. A constraint function can return True or False and is called whenever the relation is assigned a new value. If no candidate key is specified for a relation, one is assumed comprising all the attributes in the relation (this is displayed in representations as {'PK':(Key, None)}). As another example:
>>> COURSE = Relation(["CourseId", "Title"],
... [('C1', 'Database'),
... ('C2', 'HCI'),
... ('C3', 'Op Systems'),
... ('C4', 'Programming'),
... ],
... {'PK':(Key, ["CourseId"])}
... )
Another pre-defined constraint (function wrapper) is ForeignKey. It takes a relation name and a mapping of foreign key attributes to candidate key attributes as parameters, e.g.:
>>> IS_ENROLLED_ON = Relation(["StudentId", "CourseId"],
... [('S1', 'C1'),
... ('S1', 'C2'),
... ('S2', 'C1'),
... ('S3', 'C3'),
... ('S4', 'C1'),
... ],
... {'FKS':(ForeignKey, ('IS_CALLED', {"StudentId":"StudentId"})),
... 'FKC':(ForeignKey, ('COURSE', {"CourseId":"CourseId"}))}
... )
Here, two foreign keys are declared to ensure referential integrity between this relation and the relations referred to by IS_CALLED and COURSE.
In a number of places we need to pass expressions, e.g. restrictions (where clauses). Python has a built-in way of defining such expressions with anonymous functions using the lambda keyword. So an example restriction for the above IS_CALLED relation could be:
>>> print IS_CALLED.where(lambda t: t.Name == 'Boris')
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
In this example, the lambda expression is passed to the relation's where function and the expression introduces a range variable, t, which will stand for each Tuple in the relation. The expression itself, the part after the colon, tests whether the Name attribute of each tuple is equal to 'Boris': if it is then the tuple is included in the result. Any Python expression can be passed this way. So here, complex boolean expressions including boolean operators and function calls can be built, e.g.
>>> print IS_CALLED.where(lambda t: t.Name.startswith('B') and t.StudentId.endswith('5'))
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S5 | Boris |
+-----------+-------+
>>> print IS_CALLED.where(lambda t: 'A' < t.Name[0] < 'D')
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S3 | Cindy |
| S5 | Boris |
+-----------+-------+
>>> print IS_CALLED.where(lambda t: t["Name"].startswith('B'))
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
Of course, simple boolean expressions can also be used, e.g.
>>> print IS_CALLED.where(lambda t: True)
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> print IS_CALLED.where(lambda t: False)
+-----------+------+
| StudentId | Name |
+===========+======+
+-----------+------+
It's perhaps worth noting that the where function is really just shorthand for a natural join. Take the first example:
>>> print IS_CALLED.where(lambda t: t.Name == 'Boris')
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
This relational calculus based where clause can be rephrased using the relational algebra's AND operator (in this case acting as the natural join):
>>> print IS_CALLED & Relation(["Name"], [('Boris',)])
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
Many of the relational methods provided are in fact macros implemented using only a few fundamental relational operators, such as AND.
Another place lambda expressions can be used is when defining virtual relation variables. For example the earlier example:
>>> def vIS_CALLED_caps():
... return IS_CALLED.extend(['NameCaps'], lambda t: {'NameCaps': t.Name.upper()}).remove(['Name'])
>>> IS_CALLED_caps = Relation(["StudentId", "NameCaps"], vIS_CALLED_caps)
>>> print IS_CALLED_caps
+-----------+----------+
| StudentId | NameCaps |
+===========+==========+
| S1 | ANNE |
| S2 | BORIS |
| S3 | CINDY |
| S4 | DEVINDER |
| S5 | BORIS |
+-----------+----------+
Could be re-coded using lambda in a more concise way as:
>>> IS_CALLED_caps = Relation(["StudentId", "NameCaps"],
... lambda: IS_CALLED.extend(["NameCaps"], lambda t: {
... "NameCaps": t.Name.upper()}).remove(["Name"]))
>>> print IS_CALLED_caps
+-----------+----------+
| StudentId | NameCaps |
+===========+==========+
| S1 | ANNE |
| S2 | BORIS |
| S3 | CINDY |
| S4 | DEVINDER |
| S5 | BORIS |
+-----------+----------+
Lambda expressions can also be used as general constraints. On relations, another pre-defined constraint is Constraint. This takes a function that must evaluate to True for the constraint to hold, e.g.:
>>> EXAM_MARK = Relation(["StudentId", "CourseId", "Mark"],
... [('S1', 'C1', 85),
... ('S1', 'C2', 49),
... ('S2', 'C1', 49),
... ('S3', 'C3', 66),
... ('S4', 'C1', 93),
... ],
... {'PK':(Key, ["StudentId", "CourseId"]),
... 'MarkRange': (Constraint, lambda r: ALL(r, lambda t: 0 <= t.Mark <= 100))}
... )
Here, the 'MarkRange' Constraint uses the ALL relational operator (discussed below) to ensure that all Marks in this relation are between 0 and 100. Note the Constraint works at the relation level and its range variable is r in the example. Useful operators at this level are ALL, ANY, IS_EMPTY, and the relational comparison operators discussed below, because they all take relations and return a boolean result.
Here are some conversion functions to map between relations and tuples:
This static method returns a relation from a tuple:
>>> r1 = Relation.fromTuple({'CourseId':'C1', 'Title':'Database'})
>>> print r1
+----------+----------+
| CourseId | Title |
+==========+==========+
| C1 | Database |
+----------+----------+
It can also take an extra parameter to specify a set of constraints:
>>> r1 = Relation.fromTuple({'CourseId':'C1', 'Title':'Database'}, {'PK':(Key, ['CourseId'])})
>>> print r1
+----------+----------+
| CourseId | Title |
+==========+----------+
| C1 | Database |
+----------+----------+
This can apply only to a single-tuple relation and returns a tuple from that relation:
>>> t1 = r1.toTuple()
>>> print t1
Tuple(CourseId='C1', Title='Database')
>>> print t1.Title
Database
This static method returns a relation from a list of tuples:
>>> r2 = Relation.fromTupleList([{'CourseId':'C1', 'Title':'Database'},
... {'CourseId':'C4', 'Title':'Programming'},
... {'CourseId':'C3', 'Title':'Op Systems'},
... {'CourseId':'C2', 'Title':'HCI'}])
>>> print r2
+----------+-------------+
| CourseId | Title |
+==========+=============+
| C1 | Database |
| C4 | Programming |
| C3 | Op Systems |
| C2 | HCI |
+----------+-------------+
It can also take an extra parameter to specify a set of constraints:
>>> r2 = Relation.fromTupleList([{'CourseId':'C1', 'Title':'Database'},
... {'CourseId':'C4', 'Title':'Programming'},
... {'CourseId':'C3', 'Title':'Op Systems'},
... {'CourseId':'C2', 'Title':'HCI'}],
... {'PK':(Key, ['CourseId'])})
>>> print r2
+----------+-------------+
| CourseId | Title |
+==========+-------------+
| C1 | Database |
| C4 | Programming |
| C3 | Op Systems |
| C2 | HCI |
+----------+-------------+
This returns a list of tuples from the relation. Since relations are sets they can have no order, so to iterate through all the tuples in a relation you must use this method to first extract a list of tuples from the relation.
>>> ts = r2.toTupleList()
>>> print ts
[Tuple(CourseId='C1', Title='Database'), Tuple(CourseId='C4', Title='Programming'), Tuple(CourseId='C3', Title='Op Systems'), Tuple(CourseId='C2', Title='HCI')]
This list can then be iterated over in the usual ways, e.g:
>>> for t in ts:
... print t.Title
Database
Programming
Op Systems
HCI
>>> print [t.Title for t in ts if t.CourseId=='C4']
['Programming']
>>> for t in reversed(ts):
... print t.Title
HCI
Op Systems
Programming
Database
>>> print len(ts)
4
>>> print ts[0]
Tuple(CourseId='C1', Title='Database')
>>> print ts[-1]
Tuple(CourseId='C2', Title='HCI')
This is also the way to access the tuples in a pre-defined order. The toTupleList method can take an extra parameter to define a sort order. The sort parameter is a pair (ascending, attribute-list) where ascending is a boolean flag to indicate whether to sort in ascending order or not, and the attribute-list specifies the attributes to sort on.
>>> tss = r2.toTupleList((True, ['Title']))
>>> print [t.Title for t in tss]
['Database', 'HCI', 'Op Systems', 'Programming']
>>> tss = r2.toTupleList((False, ['CourseId']))
>>> print [t.CourseId for t in tss]
['C4', 'C3', 'C2', 'C1']
The renderToHTML method, mentioned earlier, is built upon the toTupleList method and also allows this sort parameter, e.g:
>>> print r2.renderHTML(sort=(True, ['Title']))

CourseId	Title

C1	Database

C2	HCI

C3	Op Systems

C4	Programming

Which in a browser becomes:
CourseId Title C1 Database C2 HCI C3 Op Systems C4 Programming
A number of boolean operators are available to compare the values of two relations. These are all implemented with the obvious overloaded Python comparisons.
>>> print IS_CALLED == Relation(["StudentId", "Name"],
... [('S1', 'Anne'),
... ('S2', 'Boris'),
... ('S3', 'Cindy'),
... ('S4', 'Devinder'),
... ('S5', 'Boris'),
... ])
True
A useful shorthand for testing equality against an empty relation is to use the IS_EMPTY function:
>>> print IS_EMPTY(IS_CALLED.where(lambda t: t.StudentId=='S99'))
True
>>> print not IS_EMPTY(IS_CALLED)
True
>>> print IS_CALLED != COURSE
True
>>> print not IS_CALLED == COURSE
True
>>> print IS_CALLED.where(lambda t: t.StudentId=='S3') < IS_CALLED
True
>>> print IS_CALLED.where(lambda t: t.StudentId.startswith('S')) < IS_CALLED
False
>>> print IS_CALLED.where(lambda t: t.StudentId=='S3') <= IS_CALLED
True
>>> print IS_CALLED.where(lambda t: t.StudentId.startswith('S')) <= IS_CALLED
True
>>> print IS_CALLED.where(lambda t: t.StudentId=='S3') <= IS_CALLED.where(lambda t: t.StudentId.startswith('S')) <= IS_CALLED
True
>>> print IS_CALLED > IS_CALLED.where(lambda t: t.StudentId=='S3')
True
>>> print IS_CALLED > IS_CALLED.where(lambda t: t.StudentId.startswith('S'))
False
>>> print IS_CALLED >= IS_CALLED.where(lambda t: t.StudentId=='S3')
True
>>> print IS_CALLED >= IS_CALLED.where(lambda t: t.StudentId.startswith('S'))
True
This is effectively the same as the subset comparison:
>>> print IS_CALLED.where(lambda t: t.StudentId=='S3') in IS_CALLED
True
The membership operator can also be passed a tuple:
>>> print Tuple(StudentId='S3', Name='Cindy') in IS_CALLED
True
>>> print Tuple(StudentId='S3', Name='Bob') in IS_CALLED
False
>>> print Tuple(StudentId='S3', Name='Cindy') not in IS_CALLED
False
>>> print Tuple(StudentId='S3', Name='Bob') not in IS_CALLED
True
We use a small core of relational operators to deliver a large number of operations. For example, we use & (relational AND) to provide natural join, intersection and Cartesian product, and we use it as the basis for implementing restriction and extension. A number of other operators are defined as macros on top of the core ones, e.g. GROUP, and this number can easily be increased. The ideas behind this approach can be found in The Third Manifesto chapter 5.
One of the powerful uses of & is the natural join. This joins relations together on their commonly named attributes. To make the most of this, without having to rename attributes before each join, use the same name for the same attributes across relations, e.g. if a key on one relation is named "product_code" then use that same name in all other relations in case they need to be joined. Naming it "code" on the product relation and "product_code" on other relations would require the rename operator to be used before doing a natural join (not to mention making the two attributes appear to be different things).
The relational operators are defined as Python functions taking, and usually returning, relations. Many of the common ones are also defined as methods and operators on the Relation class.
Some basic operations on a relation now presented.
This is so called because a relation can be thought of as representing a point in n-dimensional space (where n is the number of attributes) and just selecting a few of them is akin to projecting that point onto the chosen axes. Note once again that since a relation body is a set of tuples, there are no duplicate tuples.
>>> print IS_CALLED.project(['Name'])
+----------+
| Name |
+==========+
| Anne |
| Boris |
| Cindy |
| Devinder |
+----------+
>>> print IS_CALLED(['Name'])
+----------+
| Name |
+==========+
| Anne |
| Boris |
| Cindy |
| Devinder |
+----------+
>>> print IS_CALLED.remove(['Name'])
+-----------+
| StudentId |
+===========+
| S1 |
| S2 |
| S3 |
| S4 |
| S5 |
+-----------+
>>> print IS_CALLED.remove(['Name', 'StudentId']) == IS_CALLED.project([]) == IS_CALLED([]) == DEE
True
This is crucial to our implementation since attributes with the same name are considered to represent the same thing. The mapping of old to new attribute name(s) is given as a Python dictionary (or indeed a Tuple would also do).
>>> print IS_CALLED.rename({'Name':'NewName'})
+-----------+----------+
| StudentId | NewName |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> print IS_CALLED.rename({'StudentId':'NewId', 'Name':'NewName'})
+-------+----------+
| NewId | NewName |
+=======+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-------+----------+
This is also known as relational selection, but that can be confusing because of the SELECT in SQL which is actually for projection.
>>> print IS_CALLED.where(lambda t: t.StudentId=='S4')
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S4 | Devinder |
+-----------+----------+
If you think about it, these are all the same thing - it just depends on whether the relations have some, none, or all of their attributes in common. We implement them all using the AND relational operator using the Python &. Note that since a relation heading is a set of attributes, there are no duplicate attributes.
>>> print IS_CALLED & IS_ENROLLED_ON
+----------+-----------+----------+
| CourseId | StudentId | Name |
+==========+===========+==========+
| C1 | S1 | Anne |
| C2 | S1 | Anne |
| C1 | S2 | Boris |
| C3 | S3 | Cindy |
| C1 | S4 | Devinder |
+----------+-----------+----------+
Beware: this kind of join can be very large and is almost always meaningless.
>>> print IS_CALLED & COURSE
+----------+-----------+----------+-------------+
| CourseId | StudentId | Name | Title |
+==========+===========+==========+=============+
| C1 | S1 | Anne | Database |
| C1 | S2 | Boris | Database |
| C1 | S3 | Cindy | Database |
| C1 | S4 | Devinder | Database |
| C1 | S5 | Boris | Database |
| C2 | S1 | Anne | HCI |
| C2 | S2 | Boris | HCI |
| C2 | S3 | Cindy | HCI |
| C2 | S4 | Devinder | HCI |
| C2 | S5 | Boris | HCI |
| C3 | S1 | Anne | Op Systems |
| C3 | S2 | Boris | Op Systems |
| C3 | S3 | Cindy | Op Systems |
| C3 | S4 | Devinder | Op Systems |
| C3 | S5 | Boris | Op Systems |
| C4 | S1 | Anne | Programming |
| C4 | S2 | Boris | Programming |
| C4 | S3 | Cindy | Programming |
| C4 | S4 | Devinder | Programming |
| C4 | S5 | Boris | Programming |
+----------+-----------+----------+-------------+
>>> print IS_CALLED.where(lambda t: t.Name[0] < 'C') & IS_CALLED.where(lambda t:t.Name[0] > 'A')
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
Note that this is equivalent to:
>>> print IS_CALLED.where(lambda t: t.Name[0] < 'C' and t.Name[0] > 'A')
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S2 | Boris |
| S5 | Boris |
+-----------+-------+
These are the same thing - it just depends on whether the relations have any of their attributes in common. We implement them all using the OR relational operator using the Python |. For pragmatic reasons, we only implement the Union operator, i.e. where the relations have all of their attributes in common. The more general Or would need to handle an infinite (impossible) number of alternatives.
>>> print IS_CALLED.where(lambda t: t.Name[0] > 'C') | IS_CALLED.where(lambda t:t.Name[0] < 'B')
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S4 | Devinder |
| S1 | Anne |
+-----------+----------+
Note that this is equivalent to:
>>> print IS_CALLED.where(lambda t: t.Name[0] > 'C' or t.Name[0] < 'B')
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S4 | Devinder |
+-----------+----------+
Note that, unlike intersection and union, this is not commutative: which relation is mentioned first does make a difference (excuse the pun). It is implemented using the MINUS relational operator.
>>> print IS_CALLED - IS_CALLED.where(lambda t:t.Name[0] < 'B')
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
This is used to add new attributes to relations. First, the list of the names of the extra attributes is passed, followed by a lambda expression returning a dictionary containing the attribute values for each tuple. The values can refer to the range variable introduced by the lambda to access tuple values. It is implemented using the EXTEND relational operator which in turn is implemented using the AND relational operator (can you see how?).
>>> print IS_CALLED.extend(['Initial'], lambda t: {'Initial':t.Name[:1]})
+---------+-----------+----------+
| Initial | StudentId | Name |
+=========+===========+==========+
| A | S1 | Anne |
| B | S2 | Boris |
| C | S3 | Cindy |
| D | S4 | Devinder |
| B | S5 | Boris |
+---------+-----------+----------+
Note that this does not modify the original relation.
These operators take relations and return scalar values according to some lambda expression (except in the case of COUNT which simply counts the number of tuples). If the relation has a single attribute then the expression defaults to it.
The minimum.
>>> print MIN(EXAM_MARK, lambda t: t.Mark)
49
>>> print MIN(EXAM_MARK(['Mark']))
49
The expression in this case must return a boolean value. If all of these are True then ALL returns True, and False otherwise.
>>> print ALL(EXAM_MARK, lambda t: 0 <= t.Mark <= 100)
True
>>> print ALL(EXAM_MARK, lambda t: t.Mark > 90)
False
The expression in this case must return a boolean value. If any of these are True then ANY returns True, and False otherwise.
>>> EXAM_MARK_HIGH_FLAG = EXAM_MARK.extend(['High'], lambda t: {'High': t.Mark > 90})
>>> print EXAM_MARK_HIGH_FLAG
+-------+-----------+----------+------+
| High | StudentId | CourseId | Mark |
+=======+===========+==========+======+
| False | S1 | C1 | 85 |
| False | S1 | C2 | 49 |
| False | S2 | C1 | 49 |
| False | S3 | C3 | 66 |
| True | S4 | C1 | 93 |
+-------+-----------+----------+------+
>>> print ANY(EXAM_MARK_HIGH_FLAG, lambda t: t.High)
True
This is obviously just a shorthand for COUNT(r) == 0.
>>> print IS_EMPTY(IS_ENROLLED_ON)
False
>>> print IS_EMPTY(IS_ENROLLED_ON.where(lambda t: t.StudentId=='S99'))
True
>>> print IS_EMPTY(DUM)
True
>>> print IS_EMPTY(DEE)
False
This is a shorthand for converting a tuple into a relation, implemented by extending DEE.
>>> print GENERATE({'x':50, 'y':100})
+-----+----+
| y | x |
+=====+====+
| 100 | 50 |
+-----+----+
>>> print GENERATE(Tuple(x=50, y=100))
+-----+----+
| y | x |
+=====+====+
| 100 | 50 |
+-----+----+
>>> print DIVIDE_SIMPLE(IS_CALLED, IS_ENROLLED_ON)
+----------+-------+
| CourseId | Name |
+==========+=======+
| C2 | Anne |
| C3 | Cindy |
+----------+-------+
This takes two relations, the heading of the second must be a projection of the first, plus a tuple returning one or more scalar summary expressions. If we take the EXAM_MARK relation variable, which looks like:
>>> print EXAM_MARK
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+------+
| S1 | C1 | 85 |
| S1 | C2 | 49 |
| S2 | C1 | 49 |
| S3 | C3 | 66 |
| S4 | C1 | 93 |
+-----------+----------+------+
We can find the maximum Mark per marked Course like this:
>>> print SUMMARIZE(EXAM_MARK, EXAM_MARK(["CourseId"]), {'TopScore':(MAX, lambda t: t.Mark)})
+----------+----------+
| CourseId | TopScore |
+==========+==========+
| C1 | 93 |
| C2 | 49 |
| C3 | 66 |
+----------+----------+
And we can count the marks for every course like this (note that there is an entry for the course having no marks):
>>> print SUMMARIZE(EXAM_MARK, COURSE(["CourseId"]), {'Takers':(COUNT, None)})
+----------+--------+
| CourseId | Takers |
+==========+========+
| C1 | 3 |
| C2 | 1 |
| C3 | 1 |
| C4 | 0 |
+----------+--------+
This converts relations into relations with relation-valued attributes (RVAs), and vice versa.
>>> A = GROUP(IS_CALLED, ['StudentId'], 'StudentIds')
>>> print A
+----------+---------------+
| Name | StudentIds |
+==========+===============+
| Anne | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S1 | |
| | +-----------+ |
| Boris | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S2 | |
| | | S5 | |
| | +-----------+ |
| Cindy | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S3 | |
| | +-----------+ |
| Devinder | +-----------+ |
| | | StudentId | |
| | +===========+ |
| | | S4 | |
| | +-----------+ |
+----------+---------------+
>>> B = UNGROUP(A, 'StudentIds')
>>> print B
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S5 | Boris |
| S3 | Cindy |
| S4 | Devinder |
+-----------+----------+
>>> A = WRAP(EXAM_MARK, ['CourseId', 'Mark'], 'CourseMark')
>>> print A
+-------------------------------+-----------+
| CourseMark | StudentId |
+===============================+===========+
| Tuple(CourseId='C1', Mark=85) | S1 |
| Tuple(CourseId='C2', Mark=49) | S1 |
| Tuple(CourseId='C1', Mark=49) | S2 |
| Tuple(CourseId='C3', Mark=66) | S3 |
| Tuple(CourseId='C1', Mark=93) | S4 |
+-------------------------------+-----------+
>>> print UNWRAP(A, 'CourseMark')
+----------+-----------+------+
| CourseId | StudentId | Mark |
+==========+===========+======+
| C1 | S1 | 85 |
| C2 | S1 | 49 |
| C1 | S2 | 49 |
| C3 | S3 | 66 |
| C1 | S4 | 93 |
+----------+-----------+------+
This joins two relations and then projects back onto the first one. It is very useful for finding just those tuples in one relation that have a counterpart in another, hence the alias MATCHING. For example, "find all students who are enrolled on at least one course":
>>> print SEMIJOIN(IS_CALLED, IS_ENROLLED_ON)
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
+-----------+----------+
For example, "find students who are enrolled on no course at all":
>>> print SEMIMINUS(IS_CALLED, IS_ENROLLED_ON)
+-----------+-------+
| StudentId | Name |
+===========+=======+
| S5 | Boris |
+-----------+-------+
This gives a handy shorthand for performing the natural join and then removing any attributes that were common to the relations.
>>> print COMPOSE(IS_ENROLLED_ON, COURSE)
+-----------+------------+
| StudentId | Title |
+===========+============+
| S1 | Database |
| S2 | Database |
| S4 | Database |
| S1 | HCI |
| S3 | Op Systems |
+-----------+------------+
This operator is especially attractive if we think of a relation as a function: 'calling' the function with another relation as a parameter can be achieved by performing a natural join. For example, suppose we have a function-based relation, plus, with a heading of ['x', 'y', 'z']. Suppose the tuples of this relation are all the possible ones where x + y = z. One implementation of such a function-based relation could be:
>>> def plusfn(trx):
... """Plus (could just as well be called minus)"""
... if set(['x', 'y']).issubset(trx.attributes()) and not set(['z']).issubset(trx.attributes()):
... return [Tuple(x=trx.x, y=trx.y, z=trx.x + trx.y)]
... if set(['x', 'z']).issubset(trx.attributes()) and not set(['y']).issubset(trx.attributes()):
... return [Tuple(x=trx.x, y=trx.z - trx.x, z=trx.z)]
... if set(['y', 'z']).issubset(trx.attributes()) and not set(['x']).issubset(trx.attributes()):
... return [Tuple(x=trx.z - trx.y, y=trx.y, z=trx.z)]
...
... if set(['x', 'y', 'z']).issubset(trx.attributes()):
... if trx.x + trx.y == trx.z:
... return [Tuple()] #DEE, i.e. True #todo: should really return trx(x,y,z) - no matter?
... else:
... return [] #DUM, i.e. False
...
... raise RelationException("Plus: Infinite rows") #no x,y or z
... #Note: we could go further and return tuples given just one attribute
... # or indeed we could start yielding infinite combinations if no attributes are passed
>>> plus = Relation(["x", "y", "z"], plusfn)
And it could be used to test whether an expression is valid or not: a returned tuple means True (DEE), no tuple means False (DUM).
>>> print GENERATE({'x':3, 'y':4, 'z':7}) & plus #i.e. is 3 + 4 = 7?
+---+---+---+
| y | x | z |
+===+===+===+
| 4 | 3 | 7 |
+---+---+---+
>>> print GENERATE({'x':4, 'y':4, 'z':7}) & plus #i.e. is 4 + 4 = 7?
+---+---+---+
| y | x | z |
+===+===+===+
+---+---+---+
Also, it could be used to fill in the blank:
>>> print GENERATE({'x':3, 'y':4}) & plus #i.e. what's 3 + 4?
+---+---+---+
| y | x | z |
+===+===+===+
| 4 | 3 | 7 |
+---+---+---+
>>> print GENERATE({'z':7, 'y':4}) & plus #i.e. what's 7 - 4?
+---+---+---+
| y | x | z |
+===+===+===+
| 4 | 3 | 7 |
+---+---+---+
The advantages of using a natural join in this way over standard functions is that it takes and returns a relation. So multiple questions can be asked at once:
>>> print Relation(["x", "y"],
... [(3, 4),
... (7, 8),
... (11, 23)]) & plus #i.e. what are 3 + 4, 7 + 8 and 11 + 23?
+----+----+----+
| y | x | z |
+====+====+====+
| 4 | 3 | 7 |
| 8 | 7 | 15 |
| 23 | 11 | 34 |
+----+----+----+
And if the function-based relation had more than one result for a given tuple, e.g. square root would return -2 and +2 for 4, then it could simply return multiple results.
This whole approach could be made syntactically simpler using composition. Using a function-based relation as a function (or indeed a mathematical operator) could be done with COMPOSE(Relation(["X", "Y"], [(3, 4)]), plus).
>>> print COMPOSE(GENERATE({'x':3, 'y':4}), plus) #i.e. what's 3 + 4?
+---+
| z |
+===+
| 7 |
+---+
This is now looking more like a call to a plus function with the COMPOSE making sure that only the new information, the result, is returned. Of course it's really still performing a natural join on two relations. We could go further and extract the result as a number.
>>> print COMPOSE(GENERATE({'x':3, 'y':4}), plus).toTuple().z #i.e. what's 3 + 4?
7
In the future, a Python operator may be overridden to implement COMPOSE. For example if we override % to be relational composition then we could use something like: GENERATE({'x':3, 'y':4}) % plus.
This operator is used to traverse tree-like structures, such as a bill-of-materials. It takes as input a binary relation comprising parent and child pairs and returns a relation that has all hierarchies fully expanded. For example:
>>> MM = Relation(["MAJOR_P#", "MINOR_P#"],
... [{"MAJOR_P#":'P1', "MINOR_P#":'P2'},
... {"MAJOR_P#":'P1', "MINOR_P#":'P3'},
... {"MAJOR_P#":'P2', "MINOR_P#":'P3'},
... {"MAJOR_P#":'P2', "MINOR_P#":'P4'},
... {"MAJOR_P#":'P3', "MINOR_P#":'P5'},
... {"MAJOR_P#":'P4', "MINOR_P#":'P6'},
... ])
>>> print TCLOSE(MM)
+----------+----------+
| MAJOR_P# | MINOR_P# |
+==========+==========+
| P1 | P2 |
| P1 | P3 |
| P2 | P3 |
| P2 | P4 |
| P3 | P5 |
| P4 | P6 |
| P1 | P4 |
| P1 | P5 |
| P2 | P5 |
| P2 | P6 |
| P1 | P6 |
+----------+----------+
This restricts a relation to tuples with a number of values after ranking them by the given attribute(s). For example, to find the three lowest marks:
>>> print QUOTA(EXAM_MARK, 3, ['Mark'])
+----------+-----------+------+
| CourseId | StudentId | Mark |
+==========+===========+======+
| C2 | S1 | 49 |
| C1 | S2 | 49 |
| C3 | S3 | 66 |
+----------+-----------+------+
This operator takes an optional parameter (asc) which, if set False, sorts the tuples in descending rank before the quota is taken, e.g. to find the top three marks:
>>> print QUOTA(EXAM_MARK, 3, ['Mark'], False)
+----------+-----------+------+
| CourseId | StudentId | Mark |
+==========+===========+======+
| C1 | S1 | 85 |
| C3 | S3 | 66 |
| C1 | S4 | 93 |
+----------+-----------+------+
Note: this could return a higher or lower number of tuples than the desired number if there are ties or not enough values.
To modify a relation variable, like any other variable, you assign a value to it. Since the values of relations are often large, we introduce a shorthand, insert, for adding tuples to an existing relation variable. This shorthand really just performs a UNION (|) between the original value and the given relation (so the two relations must have the same heading).
>>> IS_CALLED.insert(Relation(["StudentId", "Name"], [('S100', 'New'), ('S101', 'New2')]))
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
| S100 | New |
| S101 | New2 |
+-----------+----------+
An alternative is to use the inplace | assignment operator, |=:
>>> IS_CALLED |= Relation(["StudentId", "Name"], [('S102', 'New3'), ('S103', 'New4')])
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
| S100 | New |
| S101 | New2 |
| S102 | New3 |
| S103 | New4 |
+-----------+----------+
There is also a version that takes a single tuple:
>>> IS_CALLED |= Tuple(StudentId='S104', Name='New5')
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
| S100 | New |
| S101 | New2 |
| S102 | New3 |
| S103 | New4 |
| S104 | New5 |
+-----------+----------+
We also introduce a shorthand, delete, for removing tuples from an existing relation variable. This shorthand really just performs a MINUS (-) between the original value and the given relation (so the two relations must have the same heading).
>>> IS_CALLED.delete(Relation(["StudentId", "Name"], [('S100', 'New'), ('S101', 'New2')]))
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
| S102 | New3 |
| S103 | New4 |
| S104 | New5 |
+-----------+----------+
An alternative is to use the inplace - assignment operator, -=:
>>> IS_CALLED -= Relation(["StudentId", "Name"], [('S102', 'New3'), ('S103', 'New4')])
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
| S104 | New5 |
+-----------+----------+
There is also a version that takes a single tuple:
>>> IS_CALLED -= Tuple(StudentId='S104', Name='New5')
>>> print IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+----------+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
To delete all tuples, pass itself:
>>> EXAM_MARK_HIGH_FLAG.delete(EXAM_MARK_HIGH_FLAG)
>>> print EXAM_MARK_HIGH_FLAG
+------+-----------+----------+------+
| High | StudentId | CourseId | Mark |
+======+===========+==========+======+
+------+-----------+----------+------+
And to destroy the relation variable altogether, use the standard Python del() method:
>>> del(EXAM_MARK_HIGH_FLAG)
>>> print EXAM_MARK_HIGH_FLAG
Traceback (most recent call last):
...
NameError: name 'EXAM_MARK_HIGH_FLAG' is not defined
Another shorthand, update, is for updating selected tuples in an existing relation variable. This shorthand really just performs a delete followed by an insert, with some special copying between the deleted tuples and the inserted tuples. For example, if we want to update all exam marks below 70 to 0:
>>> print EXAM_MARK
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+------+
| S1 | C1 | 85 |
| S1 | C2 | 49 |
| S2 | C1 | 49 |
| S3 | C3 | 66 |
| S4 | C1 | 93 |
+-----------+----------+------+
>>> EXAM_MARK.update(lambda t: t.Mark < 70, ['Mark'], lambda u: {'Mark':0})
>>> print EXAM_MARK
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+------+
| S1 | C1 | 85 |
| S4 | C1 | 93 |
| S1 | C2 | 0 |
| S2 | C1 | 0 |
| S3 | C3 | 0 |
+-----------+----------+------+
The first boolean expression is used to determine which tuples to update - this is the same format used in Restriction (the where method). Then comes the list of attributes to be updated, followed by another lambda expression that returns a dictionary containing the new values for each attribute - this is the same format used in Extension (the extend method). The values here can refer to the pre-update tuple values by prefixing their names with '_OLD_', for example to remove 10 from each Mark over 9:
>>> EXAM_MARK.update(lambda t: t.Mark >= 10, ['Mark'], lambda u: {'Mark':u._OLD_Mark - 10})
>>> print EXAM_MARK
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+------+
| S1 | C2 | 0 |
| S2 | C1 | 0 |
| S3 | C3 | 0 |
| S1 | C1 | 75 |
| S4 | C1 | 83 |
+-----------+----------+------+
One of the features of Dee is that adding new relational operators is easy and encouraged. Simply define a standard Python function taking and returning relations. For example, the transitive closure operator TCLOSE, used to explode a tree structure and discussed earlier, is implemented like this:
def TCLOSE(r):
"""Transitive closure (an example of a recursive relational operator)"""
if len(r.heading()) != 2:
raise RelationInvalidOperationException(r, "TCLOSE expects a binary relation, e.g. with a heading ['X', 'Y']")
X, Y = r.heading()
TTT = r | (COMPOSE( r, r.rename({Y:'_Z', X:Y}) ).rename({'_Z':Y}))
if TTT == r:
return TTT
else:
return TCLOSE(TTT)
Notice that this takes a single relation, asserts that it has two attributes and then recursively defines itself to return a relation. The simplicity of the definition owes much to the power of the basic relational operators, the macros defined on them, and the Python language itself.
We currently define a base Database class (in DeeDatabase.py) which provides a namespace for grouping relation variables (base and virtual) together. It also acts as a unit of persistence for both defining, storing and loading relation variables and for transactions. Each new Database should descend from this base class. The initial base relation variable definitions and data should be added and any virtual relation variable definitions and supporting functions.
Each database has its own catalog: a set of relations that describe the database (including itself):
- relations
- attributes
- constraints
- constraint_attributes
When a database is imported, the relation variables it holds are loaded from storage. When the program that imported the database is finished, the database (i.e. all its relation variables) are stored to the storage area (e.g. disk). The database is also stored upon a transaction commit - see below.
The database construction method (__init__ in Python) is called when a database is first created or loaded from storage. It is used to define initial values for relation variables, e.g.:
class darwen_Database(Database):
def __init__(self, name):
"""Define initial relvars and their initial values here
(Called once on database creation)"""
Database.__init__(self, name)
if 'IS_CALLED' not in self:
print "Adding IS_CALLED..."
self.IS_CALLED = Relation(["StudentId", "Name"],
[('S1', 'Anne'),
('S2', 'Boris'),
('S3', 'Cindy'),
('S4', 'Devinder'),
('S5', 'Boris'),
]
)
...
Also the _vinit method should be implemented to add any functions to support virtual relation variables. This is called whenever the relation variables are refreshed, e.g. after a load or rollback:
def _vinit(self):
"""Define virtual relvars/relconsts
(Called repeatedly, e.g. after database load from disk or commit)
"""
Database._vinit(self)
if 'C_ER' not in self:
print "Defining C_ER..."
self.C_ER = Relation(["CourseId", "Exam_Result"],
self.vC_ER,
{'pk':(Key, ["CourseId"])})
And then include any supporting functions:
def vC_ER(self):
return self.COURSE.extend(['Exam_Result'], lambda t:{'Exam_Result':
(self.EXAM_MARK & GENERATE({'CourseId':t.CourseId})
)(['StudentId', 'Mark'])}
)(['CourseId', 'Exam_Result']) #fixed
And load or create the database (this will run whenever the module is imported):
#Load or create the database
darwen = Database.open(darwen_Database, "darwen")
Then to use this database, import it:
>>> from darwen import *
Defining C_ER...
and refer to its relational variables within their namespace:
>>> print darwen.relations
+-----------------------+
| relation_name |
+=======================+
| IS_ENROLLED_ON |
| C_ER |
| EXAM_MARK |
| IS_CALLED |
| relations |
| COURSE |
| constraint_attributes |
| attributes |
| constraints |
+-----------------------+
>>> print COMPOSE(darwen.attributes, GENERATE({'relation_name':'IS_CALLED'}))
+----------------+
| attribute_name |
+================+
| StudentId |
| Name |
+----------------+
>>> print darwen.IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
>>> print darwen.C_ER
+----------+----------------------+
| CourseId | Exam_Result |
+==========+----------------------+
| C1 | +-----------+------+ |
| | | StudentId | Mark | |
| | +===========+======+ |
| | | S1 | 85 | |
| | | S2 | 49 | |
| | | S4 | 93 | |
| | +-----------+------+ |
| C2 | +-----------+------+ |
| | | StudentId | Mark | |
| | +===========+======+ |
| | | S1 | 49 | |
| | +-----------+------+ |
| C3 | +-----------+------+ |
| | | StudentId | Mark | |
| | +===========+======+ |
| | | S3 | 66 | |
| | +-----------+------+ |
| C4 | +-----------+------+ |
| | | StudentId | Mark | |
| | +===========+======+ |
| | +-----------+------+ |
+----------+----------------------+
Any modifications to the existing relation variables, or new ones added to the namespace, or old ones deleted from the namespace, will be persisted when the program finishes (or after a transaction commit).
We currently define a base Cluster class (in DeeCluster.py) which provides a namespace for grouping databases together. Each new Cluster should descend from this base class and import and set its database definitions.
Each cluster has its own catalog: a set of relations that describe the cluster:
- databases
The cluster construction method (__init__ in Python) is called when a cluster is first created or loaded from storage. It is used to define initial values for database variables, e.g.:
class demo_Cluster(Cluster):
def __init__(self, name):
"""Define initial databases
(Called once on cluster creation)"""
Cluster.__init__(self, name)
self.date = date
self.darwen = darwen
And load or create the cluster (this will run whenever the module is imported):
#Create the cluster
demoCluster = demo_Cluster("demo")
Then to use this cluster, import it:
>>> from demoCluster import *
and refer to its database variables within their namespace:
>>> print demoCluster.databases
+---------------+
| database_name |
+===============+
| date |
| darwen |
+---------------+
>>> print demoCluster.darwen.relations
+-----------------------+
| relation_name |
+=======================+
| IS_ENROLLED_ON |
| C_ER |
| EXAM_MARK |
| IS_CALLED |
| relations |
| COURSE |
| constraint_attributes |
| attributes |
| constraints |
+-----------------------+
then within each database, the relation variables are available:
>>> print demoCluster.darwen.IS_CALLED
+-----------+----------+
| StudentId | Name |
+===========+==========+
| S1 | Anne |
| S2 | Boris |
| S3 | Cindy |
| S4 | Devinder |
| S5 | Boris |
+-----------+----------+
These are currently controlled at the database level. The database has begin, commit and rollback methods to facilitate transactions. For example:
>>> darwen.begin()
Defining C_ER...
>>> try:
... darwen.EXAM_MARK -= darwen.EXAM_MARK.where(lambda t: t.Mark > 80)
... print darwen.EXAM_MARK
... raise Exception("Simulated error condition")
... darwen.commit()
... except:
... print "Exception - rolling back..."
... darwen.rollback()
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+======+
| S1 | C2 | 49 |
| S2 | C1 | 49 |
| S3 | C3 | 66 |
+-----------+----------+------+
Exception - rolling back...
>>> print darwen.EXAM_MARK
+-----------+----------+------+
| StudentId | CourseId | Mark |
+===========+==========+======+
| S1 | C1 | 85 |
| S1 | C2 | 49 |
| S2 | C1 | 49 |
| S3 | C3 | 66 |
| S4 | C1 | 93 |
+-----------+----------+------+
As well as using the Python interpreter to interact with relations and databases, a stand-alone web-server that gives access to a cluster of sample databases from a browser is available. To start the server and a client run:
python DeeWebDemo.py
The default browser should launch and a text box will be presented to allow Dee expressions to be entered. The expression can be evaluated by pressing the 'Evaluate' button. The default database can be changed by selecting from the drop-down list and pressing the 'Change database' button.
There are a number of areas that need more work. These include:
This should be optimised for insert/update operations where often just the new tuples need to be checked. Also more work could be done to simplify and improve the declaration of some constraints, e.g. ForeignKey, and the representation and storage of ad-hoc lambda functions.
Currently if a constraint fails during the insertion phase of an update, the deletions are not rolled back (unless this is manually controlled via a database transaction).
We would also like to use a multiple assignment mechanism, similar to Python's, to achieve parallel assignment to avoid any need for deferred constraints.
We need to implement routines to ensure relation constraints, such as candidate keys, are inferred in derived relations. We do some of this already, e.g. for the rename operator, but much more is required.
Adding and removing constraints from existing relations is not yet supported. Also database-level constraints cannot be created yet. Also actions such as deleting a relation variable that is referenced should be handled better.
With memory sizes measured in Gigabytes, the immediate intention is to keep databases in memory with a protected power supply to provide short-term durability. For longer term durability, the database can be saved to disk. This is currently done by storing the database relation variables in a single Python pickle file. If the debug_dump constant is True in DeeDatabase then a script is also written containing the latest relation definitions and data. This storage mechanism could be made more efficient (by storing incremental changes rather than the whole database) and more resilient (e.g. storing online to Amazon's S3).
The current implementation is intended to be shared by a single application, e.g. a web-server, feeding multiple clients. Work is needed to ensure that multiple threads can share the data and serialise transactions.
Some work is needed to tighten up the permitted values in Tuples. For example, whether None can ever be used and how Python objects are stored and compared.
We envisage several possible ways of accessing the data, e.g. RPC, SOAP.
These need to allow inserts, deletes and updates that can then be passed down to the base relation(s) where possible. Also an improved method for storing their definitions is needed.
Access rights and privileges need to be designed and implemented.
Obviously SQL will be around for a long time yet, so an interpreter could be built to parse SQL and generate the equivalent statements in Dee (where possible).
By working with in-memory data and using fully hashed relations we can perform very fast joins. We have some optimisation code for some relational operators, but this could be improved e.g. by introducing a ternary join operator AND(r, s, t).
As another example, the where method effectively scans the relation, filtering by the given expression. For equality checks on large relations it would be much faster to use & with the appropriate relation: then the hash join will be used instead of a scan. This optimisation can be made manually, e.g. replace r.where(lambda t: t.Name=='Find it') with r & GENERATE({'Name':'Find it'}), but it ought to be done by the system.
Perhaps we should introduce more Relation methods (such as intersect, union, join, times) to map onto the existing operators. These would simply be aliases but may make things appear more familiar. On the other hand, once it's realised that these are all just AND and OR, it might be best to keep the number of different names for the same thing to a minimum.


SAT Online Exam
Your test will begin in seconds.
Instructions
- Make sure you have a good internet connection.
- Never click the 'Back' button on the browser. This will take you out of the test and prevent the system from tracking your selected answers.
- You will have 10 minutes to complete your exam.
- Answer all questions in the exam.
- Click the 'End Test' button to submit your exam and end the test within the given time.


Uncle Tom's Cabin (Told to the Children)
by Harriet Beecher Stowe
Chapter 7: Master George and Uncle Tom
Additional Information
- Year Published: 1852
- Language: English
- Country of Origin: United States of America
- Source: Stowe, H. B. (1852). Uncle Tom's Cabin (Told to the Children). H. E. Marshall, (Ed.).
-
Readability:
- Flesch–Kincaid Level: 3.7
- Word Count: 1,169
- Genre: Historical Fiction
- Keywords: 19th century literature, american literature
- ✎ Cite This
Downloads
Haley and Tom had rattled along the dusty road for about a mile, when Haley pulled up at a blacksmith's shop. He got out to have something done to a pair of handcuffs, leaving Tom in the cart.
Tom was sitting there, very mournfully, when suddenly he heard the quick, short click of a horse's hoof behind him. Almost before he knew what was happening, George Shelby sprang into the cart. He threw his arms round Tom's neck, sobbing and scolding.
'I declare it's real mean. I don't care what they say, any of them. It's a nasty, mean shame. If I were a man, they shouldn't do it—they should not!'
'Oh, Mas'r George, this does me good,' said Tom.' I couldn't bear to go off without seein' ye. It does me real good, ye can't tell.'
Here Tom made a movement with his feet, and George's eyes fell on the chains.
'What a shame,' he cried. ' I'll knock that old fellow down, I will.'
'No, you won't, Mas'r George; and you must not talk so loud. It won't help me any, to anger him.'
'Well, I won't then, for your sake. But only to think of it—isn't it a shame? They never sent for me, nor sent me any word. If it hadn't been for Tom Lincoln, I shouldn't have heard of it. I tell you, I blew them up well, all of them, at home.'
'That wasn't right, I'm feared, Mas'r George.'
'Can't help it. I say it's a shame. Look here, Uncle Tom,' said he, turning his back to the shop, and speaking in a mysterious tone, 'I've brought you my dollar.'
'Oh, I couldn't think of takin' it, Mas'r George, noways in the world,' said Tom.
'But you shall take it,' said George. 'Look here, I told Aunt Chloe I'd do it. She advise, me just to make a hole in it, and put a string through. You can hang it round your neck, and keep it out of sight, else this mean scamp will take it away.  It would do me good.'
'No, don't, Mas'r George, for it won't do me any good.'
'Well, I won't for your sake,' said George, busily tying his dollar round Tom's neck. 'There, now button your coat tight over it, and keep it safe.  Aunt Chloe and I have been talking about it: I told her not to fear. I'll see to it. I'll tease father's life out, if he doesn't see to it.'
'Oh, Mas'r George, ye mustn't talk so 'bout your father.'
'Dear me, Uncle Tom, I don't mean anything bad.'
'And now, Mas'r George,' said Tom, 'ye must be a good boy. 'Member how many hearts is set on ye. Always keep close to your mother.  Tell ye what, Mas'r George, the Lord gives a good many things twice over, but he don't give ye a mother but once. Ye'll never see such another woman, Mas'r George—not if ye live to be a hundred years old. So, now, you hold on to her, and grow up, and be a comfort to her, there's my own good boy—you will now—won't ye?'
'Yes, I will, Uncle Tom,' said George seriously.
'And be careful of yer speaking, Mas'r George. Young boys, when they comes to your age, is wilful sometimes—it's natural they should be. But real gentlemen such as I hopes you'll be, never lets fall words that isn't 'spectful to their parents. Ye an't offended, Mas'r George?'
'No, indeed, Uncle Tom, you always give me good advice.'
'I'se older, you know,' said Tom, stroking George's curly head with his large strong hand, but speaking in a voice as tender as a mother's.
'Oh, Mas'r George, you has everything—learning, reading, writing—and you'll grow up to be a great, learned, good man. All the people on the place, and your father and mother, 'll be proud of ye. Be a good mas'r like your father, and be a Christian like your mother, Mas'r George.'
'I'll be real good, Uncle Tom, I tell you,' said George. 'And don't you be discouraged. I'll have you back yet. As I told Aunt Chloe this morning, I'll build your house over again. You shall have a room for a parlour, with a carpet on it, when I'm a man. Oh, you'll have good times yet.'
Haley now came to the shop door with the handcuffs in his hand.
'Look here, now, mister,' said George, looking at him very grandly, 'I shall let father and mother know how you treat Uncle Tom.'
'You're welcome,' replied he.
 I should think you'd feel mean,' said George.
'So long as you grand folks wants to buy men and women, I'm as good as they,' said Haley. 'It isn't any meaner to sell them than to buy them.'
'I'll never do either, when I'm a man,' said George. 'I'm ashamed this day. Good-bye, Uncle Tom,' he added, 'don't get down-hearted.'
'Good-bye, Mas'r George,' said Tom. 'God Almighty bless you.'
Away George went, and Tom looked after him until the clatter of his horse's heels died away. It was the last sound or sight of his home. But over his heart there seemed to be a warm spot where George had placed that precious dollar. Tom put up his hand and held it close to his heart.
Haley came to the cart, threw the handcuffs in, and jumping up on to the seat, drove off again.
All day long, they drove over the rough country roads. Late in the evening they arrived at a town called Washington. Haley went to a comfortable inn for the night, but poor Tom was sent to prison with handcuffs on his wrists, and heavy chains on his ankles.


|
C++ Actor Framework 0.19
|
Produces text and binary messages for the upper layer. More...
#include <lower_layer.hpp>
Public Member Functions | |
| virtual void | request_messages ()=0 |
Pulls messages from the transport until calling suspend_reading . | |
| virtual void | suspend_reading ()=0 |
Stops reading messages until calling request_messages . | |
| virtual void | begin_binary_message ()=0 |
| Begins transmission of a binary message. | |
| virtual byte_buffer & | binary_message_buffer ()=0 |
| Returns the buffer for the current binary message. | |
| virtual bool | end_binary_message ()=0 |
| Seals the current binary message buffer and ships a new WebSocket frame. | |
| virtual void | begin_text_message ()=0 |
| Begins transmission of a text message. | |
| virtual text_buffer & | text_message_buffer ()=0 |
| Returns the buffer for the current text message. | |
| virtual bool | end_text_message ()=0 |
| Seals the current text message buffer and ships a new WebSocket frame. | |
| void | shutdown () override |
| Shuts down any connection or session gracefully. | |
| void | shutdown (const error &reason) override |
| Shuts down any connection or session du to an error. | |
| virtual void | shutdown (status code, std::string_view msg)=0 |
Sends a shutdown message with custom status code and msg text. | |
| Public Member Functions inherited from caf::net::generic_lower_layer | |
| virtual multiplexer & | mpx () noexcept=0 |
| Returns the multiplexer instance that executes this protocol stack. | |
| virtual bool | can_send_more () const noexcept=0 |
| Queries whether the output device can accept more data straight away. | |
| virtual bool | is_reading () const noexcept=0 |
| Queries whether the lower layer is currently reading from its input device. | |
| virtual void | write_later ()=0 |
| Triggers a write callback after the write device signals downstream capacity. | |
| virtual void | shutdown ()=0 |
| Shuts down any connection or session gracefully. | |
| virtual void | shutdown (const error &reason) |
| Shuts down any connection or session du to an error. | |
Produces text and binary messages for the upper layer.
|
pure virtual |
Begins transmission of a binary message.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Begins transmission of a text message.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Returns the buffer for the current binary message.
Must be called between calling begin_binary_message
and end_binary_message
.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Seals the current binary message buffer and ships a new WebSocket frame.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Seals the current text message buffer and ships a new WebSocket frame.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Pulls messages from the transport until calling suspend_reading
.
Implemented in caf::net::web_socket::framing.
|
overridevirtual |
Shuts down any connection or session gracefully.
Any pending data gets flushed before closing the socket.
Implements caf::net::generic_lower_layer.
|
overridevirtual |
Shuts down any connection or session du to an error.
Any pending data gets flushed before closing the socket. Protocols with a dedicated closing handshake such as WebSocket may send the close reason to the peer.
Reimplemented from caf::net::generic_lower_layer.
|
pure virtual |
Sends a shutdown message with custom status code
and msg
text.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Stops reading messages until calling request_messages
.
Implemented in caf::net::web_socket::framing.
|
pure virtual |
Returns the buffer for the current text message.
Must be called between calling begin_text_message
and end_text_message
.
Implemented in caf::net::web_socket::framing.


2021 Toyota RAV4 Prime Is The Most Powerful RAV4 Ever
It’s the second quickest Toyota model after the Supra.
by Martin BiggThe all-new fifth-generation Toyota RAV4 has only been on sale for around a year, but Toyota has wasted no time expanding the lineup. Last month saw the debut of the first-ever Toyota RAV4 TRD Off-Road, and now another new RAV4 variant has debuted at the 2019 LA Auto Show. Say hello to the 2021 Toyota RAV4 Prime: the fastest and most powerful Toyota RAV4 ever made. Despite this, it's also the most fuel-efficient model because the Prime also happens to be the first-ever plug-in hybrid RAV4.
Based on the Toyota RAV4 Hybrid, the RAV4 Prime packs a 2.5-liter four-cylinder gas engine with a high-capacity lithium-Ion battery, a booster converter, and two electric motors producing a combined output of 302 horsepower – that's 83 more horsepower than the current RAV4 Hybrid. Unsurprisingly, this has resulted in a significant performance boost. 0-62 mph in the RAV4 Prime takes 5.8 seconds, compared to 7.8 seconds in the RAV4 Hybrid. Impressively, that makes the RAV4 Prime the second quickest Toyota model after the 2020 Toyota GR Supra.
Despite its brisk performance, the RAV4 Prime boasts impressive fuel economy and range. Toyota estimates it will achieve 90 MPGe and deliver 39 miles of electric range, which is the highest EV range of any PHEV SUV on the market. Since the larger lithium-ion battery is mounted under the floor, the RAV4 Prime's passenger space hasn't been compromised with 37.6 cu.ft of cargo space. The battery's position also gives the RAV4 Prime a low center of gravity and enhanced driving stability.
Like the RAV4 Hybrid, the RAV4 Prime has an electronic on-demand all-wheel-drive system that uses a separate rear-mounted electric motor to power the rear wheels when needed while also reducing understeer during cornering. Off-road, a selectable 'Trail' mode makes it possible to get unstuck by braking a spinning wheel and sending torque to the grounding wheel. Using the available paddle shifters, the driver can also downshift to increase the regenerative braking, resulting in greater control over hilly areas.
Toyota will offer the performance-focused 2021 RAV4 Prime in sporty SE and XSE guises. The SE trim is new for the RAV4 Prime, while the XSE is currently exclusive to the RAV4 Hybrid. The SE trim includes 18-inch painted and machined alloy wheels, an exclusive front grille design, and front lower spoiler. Piano black exterior accents and a painted grille and diffuser give the SUV a premium look.
Standard equipment includes heated front seats, an eight-way power driver's seat with lumbar adjustment, seven-inch display, blind spot monitor, a leather steering wheel and shift knob with red stitching, power liftgate, and an eight-inch touch-screen Amazon Alexa, Android Auto and Apple CarPlay support. The range-topping XSE trim, on the other hand, features a two-tone exterior paint scheme pairing a black roof with select colors, including the striking Supersonic Red.
It also rides on exclusive 19-inch alloy wheels, the largest ever offered on a hybrid RAV4, with a unique two-tone design. Vertical LED accent lights give the XSE a unique look, while the optional Adaptive Front Lighting System with headlamp auto-leveling partially aims the beams into turns as the driver steers.
Inside, the XSE comes with the RAV4's first-ever paddle shifters, along with a moonroof, unique synthetic leather seat surfaces, wireless smartphone charging, ambient lighting, auto-dimming rearview mirror with integrated garage door opener, and a nine-inch touch-screen. An optional premium package adds dynamic navigation, JBL speakers, ventilated seats, a head-up display, heated steering wheel, panoramic moonroof, digital rear-view mirror, memory driver's seat, four-way power passenger seat, kick-type power rear liftgate, and more.
The 2021 Toyota RAV4 Prime will arrive in dealers in summer 2020, with pricing to be announced at a later date.


Flatsheet is a tool for managing tabular data with a friendly editor.
This editor is a demo of the new version of Flatsheet that's being developed with the support of an OpenNews code sprint grant.
The current goals are to improve the editor UI to create the simplest possible editing experience, to create integrations with other tools, like syncing with Google Spreadsheets and dat, and to allow group collaboration on a dataset through the UI.
Get the code, submit issues, get involved
The code for this project lives on GitHub at github.com/flatsheet/editor. Please submit issues to our issues queue: github.com/flatsheet/editor/issues.


Secure-WiFi
We are sorry, we are unable to connect you at the moment.
Please try again with a different account. thank you.
Secure-Wifi Login
Secure-Wifi
No registration required. Login with your social account.


To use your own share button use the ShareService to add a custom button.
The available input for sharing parameters are url
, url
,
title
, description
, image
,
tags
and via
.
But that does not mean that you can use all or any of them. that depends on the social network and the
parameters they support, most of them only support only the url
Additional data can be added to the button which can be useful.


Step one: provide some notes for a chord.
In MEI, the notion of a chord means the "simultaneous sounding of two or more notes in the same layer with the same duration" (see Element specification). Thus, a chord is made up of two or more note elements that belong to the same voice (layer) and have an identical rhythmical structure (duration). (There are cases where you don't want to have the same duration on every note of a chord, but these are not part of this basic tutorial.)
To encode such a "simultaneous sounding", the <chord>
element is used in MEI. Its use is pretty
straightforward: Multiple <note>
elements within the same layer are enclosed by a <chord>
element and the duration attribute (@dur) is moved from the <note>
s to the <chord>
element (since the duration is the same for all notes). However, whether you write an outer <chord>
element first to add some inner <note>
elements, or whether you start with the <note>
s
and then enclose them in a <chord>
element, does not actually matter in practice.
For this tutorial, let's stick to the second approach: This means, we need some notes first.
In the editor below, please enter the following three <note>
elements:
<note pname="e" oct="4" dur="4"/>
<note pname="g" oct="4" dur="4"/>
<note pname="c" oct="5" dur="4"/>
You should then see the three notes rendered sequentially. Not much of a chord, actually. But don't worry: We will care about that right away in the next step. Until then, you may play a little bit with the attribute values to see how they influence the rendering. You will also see hints on how to write the correct code. Whenever you're ready, make sure to have the correct code in the editor, and then hit the "continue" button on the lower right.


Top-level libnet header file. More...
#include "./libnet/libnet-types.h"
#include "./libnet/libnet-macros.h"
#include "./libnet/libnet-headers.h"
#include "./libnet/libnet-structures.h"
#include "./libnet/libnet-asn1.h"
#include "./libnet/libnet-functions.h"
Go to the source code of this file.
Top-level libnet header file.
This section doesn't contain any details about libnet.h.
If you're wondering why, then that's mostly because libnet.h isn't where the action takes place. In fact, no action at all. Okay, maybe a little. But definitely not enough worth a separate man page or a detailed description. The real action goes down in some of the other files this file includes.
Which probably makes you wonder why, of all libnet*.h headers this file includes, only libnet-functions.h and libnet-macros.h are documented. My friend, you're not alone in your marveling.
You see, the guy who wrote them (Mike D. Schiffman) is gone, and the guy after him (Sam Roberts) didn't had much time left at the end of the day after bug fixing the living hell out of the source.
And if you're wondering why the rest of libnet's documentation is either full of holes or nonexistent, then (a) good question; and (b) see the previous paragraph.
Is this a sinking ship? Well, I can't answer that right now. What I can say is that it's just us now. So, "Lets (try to) make libnet great again"!
Sincerely,
Ali Abdulkadir


Can you give more detail? Where you're playing, does the Drow subrace get any penalties/advantages? What type of environment is it (high magic/low magic)? Any nerfs to spells/feats/abilities? What do you want your character to be able to do (melee/ranged/self-buffer/caster)? _________________ It's rogue, dammit, ROGUE!!!
Can you give more detail? Yes.
Where you're playing, does the Drow subrace get any penalties/advantages? Arelith; Drow Sub-race: DEX +2, CON -2, INT +2, CHA +2
What type of environment is it (high magic/low magic)? Low Magic
Any nerfs to spells/feats/abilities? Not to sure about it.
What do you want your character to be able to do (melee/ranged/self-buffer/caster)? I rather have a melee/?? .. Right now I'm using a Fighter/Rouge. I like his stealth abilities, but he seems to be very weak. What would you suggest?
Also thank you! Taino _________________ Appearance2da
Edited By DM-Taino on 09/07/07 22:27
Anything???
Taino _________________ Appearance2da
level 30 powerbuild in low magic? I'd take a Cleric 18 / Bard 2 / Red Dragon Disciple 10, that's strong in every way.
Or well, a caster, that never fails. _________________ Join the Pre-epic Character Builds Guild for builds capped at level 20 and level 30.