Subject: 4.1.1 Grammar for Search Mechanism

From: Doug Royer <[email-masked]>
Date: Sat, 12 Jan 2002 16:55:08 -0700

Assuming that the WG aggress to the (6) SQL-MIN rules (restated
below and in a previous email as (7) rules [old (3) deleted) ):

Here is my proposal for the 07 draft.

I would like to change the ABNF in 4.1.1 Grammar for Search Mechanism:

---
CHANGE capselect-min:

IN 06:

>
>  capselect-min  = "SELECT" capmin-cols "FROM" capmin-comps
>                     "WHERE" capmin-cmp

PROPOSAL:

 capselect-min	= ( "SELECT" " " capmin-cols
                    " " "FROM" " " compmin-tbl
                    " " "WHERE" " " capmin-cmp

		  / "SELECT" " " capmin-cols
                    " " "FROM" " " capmin-tbl )

 capmin-tbl	= ( comp-name / cs-id / relcal-id )

 cs-id		# The CSID of a CS for the purpose of accessing
                # the Calendar Store Properties.

 relcal-id	# A relative CAL-ID for the purpose of accessing
	        # the calendar properties for that rel-cal-id.

----

CHANGE capmin-col:

IN 06:

>    capmin-col     = # Any property name found in any of the
>                     components.

PROPOSAL:

 capmin-col       # Any property name found in the single comp-name
                  # component supplied in the FROM clause of
                  # the same QUERY property.
                  #
                  # Or a component type name (comp-name) to mean
                  # the entire contents of that contained component
                  # that exists in the component supplied in the FROM
                  # clause of the same QUERY property.

---
DELETE capmin-comps

IN 06:

>    capmin-comps   = ( comp-name / comp-name ","
>                     compmin-comps )

---

CHANGE capmin-cmp and capmin-cmp-rhs:

in 06:

>    capmin-cmp     = ( colname capmin-cmp-rhs
>                   / colname capmin-cmp-rhs
>                     capmin-logical capmin-cmp )
>
>    capmin-cmp-rhs = ( capmin-oper colvalue
>                   /   "IS" ["NOT"] "NULL" )

PROPOSAL:

     capmin-cmp     = ( colname capmin-logical colvalue )
                    / ( colname capmin-cmp-null )

     capmin-cmp-null = "IS NULL"  / "IS NOT NULL"

---

Add:

  (1) All components look like tables for the purpose of
      a VQUERY including VALARM. And their contained properties
      looked like columns in those tables.

  (2) All VAGENDAs and CS's look like tables for the purpose of a
      VQUERY. And all of their properties look like columns in
      those tables.

  (3) You CAN NOT do any cross component-type joins. And that you
      can ONLY have ONE component, OR ONE property, OR ONE VAGENDA
      OR ONE CSID or ONE CAL-ID in the the FROM clause.

  (4) Everything in the SELECT and WHERE clause MUST from the
      component type, or CSISD or CAL-ID listed in the FROM clause.

  (5) Allow the '.' to mean <table>.<column> when needed for
      contained properties or their associated contained components.
      As long as all were contained (as defined by iCalendar or CAP)
      in the SINGLE component type named in the FROM clause OR its
      contained component that MUST BE in the select clause. If
      you use a contained component in the WHERE clause, you MUST get
      ALL of that components data - (and no double '.') in the SELECT
      clause for that contained component type.

      This prevents possible cross virtual table joins that could
      occur if the WHERE clause contained information that could
      be in another virtual table from the data in the SELECT clause.

  (6) A contained component without a '.' it refers
      to <compnent>.* with the result being a properly
      formatted <component>(s) in the data stream, and correctly
      in the contained component(s).

	VALID:

		(a) SELECT VEVENT.<a-property-name> FROM VEVENT

		(b) SELECT VEVENT.VALARM FROM VEVENT

                (c) SELECT VALARM FROM VEVENT

		(d) SELECT VEVENT.* FROM VEVENT

                (e) SELECT * FROM VEVENT

                (f) SELECT * FROM VEVENT WHERE
                     VEVENT.TRIGGER < 20020201T000000Z
                     AND VEVENT.TRIGGER > 20020101T000000Z

                Note: That (b) and (c) yield the same results.

                      That (d) would include VALARM which would
                      include all of the contained VALARMs.

                      (d) and (e) yield the same
results.                      

	NOT VALID:

		(g) SELECT VEVENET.VALARM.TRIGGER FROM VEVENT

	        (h) SELECT DTSTART,UID FROM VEVENT WHERE
                     VEVENT.TRIGGER < 20020201T000000Z
                     AND VEVENT.TRIGGER > 20020101T000000Z

	         Note: (g) Is NOT valid because it contains
                           two '.' characters in the SELECT clause.

                       (h) Is NOT valid because it violates rule (5).
                           The error is that VEVENT.TRIGGER is in the
                           WHERE clause and it is not directly or
                           indirectly (by '*' or <something>.'*') in
                           the SELECT clause.

---

From: Patrice Lapierre <[email-masked]>
Date: 14 Jan 2002 08:18:50 -0500

> 	        # the calendar properties for that rel-cal-id.
...
>>      component type, or CSISD or CAL-ID listed in the FROM clause.

  I don't understand what will be accomplished by adding 
"cs-id" and "relcal-id" to the FROM clause.  

 It doesn't seem to add anything and makes the query language ambiguous.

Ambiguities:

  - What if the RELCALID of a VAGENDA is set to a component name.

     e.g. RELCALID:VEVENT

  - Given a FROM clause that includes an element that is 
    not a component name. How do you determine if it's a 
    CSID or a RELCALID?

Unnecessary:

 The following queries are taken from draft-06:

   SELECT * FROM VAGENDA WHERE RELCALID = 'relcal4'
   SELECT * FROM CALSTORE WHERE CSID = 'bobo.ex.com' 
 
 I don't understand what is gained, by the proposition.

  Another problem is that since the WHERE clause is mandatory, 
the proposed syntax forces an dummy expression:

   e.g. SELECT * FROM relcalid4 WHERE RELCALID IS NOT NULL
        SELECT * FROM bobo.ex.com WHERE CSID IS NOT NULL

>      VQUERY. And all of their properties look like columns in

By adding VAGENDA and CALSTORE to (1), (1) subsumes (2).

---

From: Doug Royer <[email-masked]>
Date: Mon, 14 Jan 2002 10:41:09 -0700

>    SELECT * FROM CALSTORE WHERE CSID = 'bobo.ex.com'

Great! - So we then need to add VAGENDA and CALSTORE to the ABFN
         in place of what I said (CSID and RELCAL-ID). My intention
         was the fact that whatever goes there, was not in the ABNF.
 
>   Another problem is that since the WHERE clause is mandatory,

No - I think that was an error in the previous drafts. There is no
need to have a WHERE clause if you are getting '*' from <table>

I think the ABNF I sent over the weekend shows it as optional: