next up previous
Next: Remaining issues Up: Syntax Previous: Creating Views

Define

Define <Name> := Select Select_Expression 
                   [ From From_Expression ] 
                   [ Where Predicate ]
                   [ With Qualified_Path_Expression_List ]

The Define command provides the meat to the view specification language. The string provided by the Name slot indicates the named object that will be created as a result of the Select... From... Where... With... command. The Select_Expression specified within the select clause will be those object(s) that will be selected and added to the database. The With component indicates those children of the objects within the Select_Expression which will also be selected. The one caveat to the path expression appearing within the With component is that each path expression must begin, or have the same prefix as, one appearing within the Select_Expression. All links between objects selected within the Select_Expression and the With clause will automatically be added. The From and Where clause function exactly as they do in a normal query. In fact the evaluation of the entire Define command will proceed similar to evaluation of a simple Select... From... Where..., with additional work being done to handle the With clause.

Examples:

define N := Select p
            From db.Students s, s.Person p
            Where C1 or C2 or C3
            With p.Phone, p.Name, p.Address

Friends2 := Select new_oem(Husband:h, Wife:w)
            From Person h, Person w
            Where h.Spouse = w and h.Sex = "Male"
            With h.?.?, w.?

The final syntactic issue to address is how to handle the addition or removal of labels from the view. The syntax and symantics for this has been heavily influenced by the update language. There are some obvious differences, but most everything follows naturally from the update language. The ``+='' operator shown below can be replaced with ``-=''.

Selector.Label  += Selector
From  From_Clause
Where Predicate

A Selector is either a name or a range variable defined within the From clause. The label is the edge that will be either added or removed (depending on the operator). Since this statement will occur within the context of a view creation (if it didn't then it would be handled as an update statement to the source database) the edge created or deleted will be an edge within the view. Considering this we can either always require the user to prepend the path expressions with the name of the view as the database selectifier, or we can assume that all names will always come from the view being created.


next up previous
Next: Remaining issues Up: Syntax Previous: Creating Views

Jason McHugh
Fri Jan 17 10:32:41 PST 1997