Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General DB Topics / DB Theory / March 2008

Tip: Looking for answers? Try searching our database.

About grammar and syntax on a possible relational language

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cimode - 11 Mar 2008 11:55 GMT
2 weeks ago, I have posted a sample of the semantics am using for the
db core that I am building...I was hoping some comments that would
help me sharpen it and make it more effective.  Here are a few
examples of what the language can do.

Considering the relation EMPLOYEE {EMP#, LNAME, DOB, SALARY}

I write...

1) for basic manipulation and definition
to define the EMPLOYEE RELATION, I write

[MAKE EMPLOYEE = {EMP# INT, LNAME CHAR, DOB DATE, SALARY INT}]

to extract basic information, I write
PRESENT2D [EMPLOYEE WITH LNAME='SMITH']

which brings a tabular representation of all EMPLOYEES with LNAME
'SMITH'

I can also write...

2) About relation definirion through derivation

[MAKE RICH_EMPLOYEE = EMPLOYEE WITH SALARY > 100000]
to derive a relation RICH_EMPLOYEE from relation EMPLOYEE by adding a
constraint over the salary

then...

PRESENT2D [RICH_EMPLOYEE]

to present all EMPLOYEES that have a salary higher than 100000

3) About defining new relations and foreign keys through subtyping.
Supposing I want to define a relation VIP_MEMBER {EMPLOYEE} wich are
all employees that make more than 100000...I can write

[MAKE RICH_EMPLOYEE = EMPLOYEE WITH SALARY > 100000]

[MAKE VIP_MEMBER = {RICH_EMPLOYEE}] with RICH_EMPLOYEE being *de
facto* a foreign key to RICH_EMPLOYEE and RICH_EMPLOYEE being *de
facto* a foreign key to EMPLOYEE.  This makes it easier to decompose
relations for normalization purposes.

I can then write
PRESENT2D [VIP_MEMBER WITH SALARY > 200000] which would have the
system actually benefit from all parent relation attributes. and would
present information in tabular format...

SUMMARY

By running the following at definition time

[MAKE EMPLOYEE = {EMP# INT, LNAME CHAR, DOB DATE, SALARY INT}]
[MAKE RICH_EMPLOYEE = EMPLOYEE WITH SALARY > 100000]
[MAKE VIP_MEMBER = {RICH_EMPLOYEE}]

I am defining 3 relations differently and applying operators while
establishing a de facto foreign key between VIP_MEMBER and
RICH_EMPLOYEE as well as RICH_EMPLOYEE and EMPLOYEE.  I use this de
facto references to be able to write

PRESENT2D [VIP_MEMBER WITH SALARY > 200000]  --> 2 implicit JOINS.

What do you guys think.  I initially thought about using SET instead
but I want to keep the idea of relation as a construct which is why I
use the verb MAKE.  I am hoping the above example wil draw some
constructive comments..

Regards...
TroyK - 11 Mar 2008 17:42 GMT
> (snip)

> SUMMARY
>
[quoted text clipped - 17 lines]
>
> Regards...

Short comment/question on the syntax:

PRESENT2D - does the name imply that there will be other n-dimensional
presentations available (PRESENT3D, e.g.)?

Why not:
[MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
(with curly braces around the derivation expression)? It seems a
little "off" to use them only sometimes.

Regarding derived relation definitions, what would the expected
behavior be for VIP_MEMBER if the derivation for RICH_EMPLOYEE were to
change after VIP_MEMBER was declared, e.g.:
[MAKE RICH_EMPLOYEE = EMPLOYEE WITH SALARY > 150000]

My assumption is that the VIP_MEMBER relation would "dynamically"
derive from the new definition. Is this correct?

TroyK
Cimode - 11 Mar 2008 18:38 GMT
> > (snip)
> > SUMMARY
[quoted text clipped - 23 lines]
> PRESENT2D - does the name imply that there will be other n-dimensional
> presentations available (PRESENT3D, e.g.)?

Yes.  Other examples of media functions are:
OLAP
SENDFTP('192.168.10.20') --> built

the purpose of theses functions is to express the modalities and
protocols by which the information is presented to users.

> Why not:
> [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
> (with curly braces around the derivation expression)? It seems a
> little "off" to use them only sometimes.
Because I reserved '[]' to relation operation and '{}' to relation
definition.  I will keep the remark in mind though

> Regarding derived relation definitions, what would the expected
> behavior be for VIP_MEMBER if the derivation for RICH_EMPLOYEE were to
[quoted text clipped - 3 lines]
> My assumption is that the VIP_MEMBER relation would "dynamically"
> derive from the new definition. Is this correct?
Yes.  VIP_MEMBER is a derived relation from RICH_EMPLOYEE that is
itself from EMPLOYEE..

Thanks for your comments...

> TroyK
Cimode - 12 Mar 2008 15:33 GMT
> > Why not:
> > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 3 lines]
> Because I reserved '[]' to relation operation and '{}' to relation
> definition.  I will keep the remark in mind though

To be more explicit {} is attribute level manipulation and [] is
relation level manipulation to keep the language as versatile as
possible.  For example

[MAKE R0 = {ATTRIBUTE0_1, ATTRIBUTE0_2}]
[MAKE R1 = {ATTRIBUTE1_1, ATTRIBUTE1_2}]
[MAKE R2 = R0 UNION R1]
PRESENT2D [R2]

does the same thing as

PRESENT2D [{ATTRIBUTE0_1, ATTRIBUTE0_2} UNION {ATTRIBUTE1_1,
ATTRIBUTE1_2}]

It is also about the coherence of the computing model behind.  The
input of the media layer is necessarily a relation.  The input of the
logical layer may either be a relation or an attribute set.
TroyK - 12 Mar 2008 17:29 GMT
> > > Why not:
> > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 21 lines]
> input of the media layer is necessarily a relation.  The input of the
> logical layer may either be a relation or an attribute set.

I see what you're aiming for and I think that I agree with the syntax.
The example that introduced the confusion for me is this:
[MAKE VIP_MEMBER = {RICH_EMPLOYEE}]

where "RICH_EMPLOYEE" refers to a relation.

TroyK
Cimode - 12 Mar 2008 17:36 GMT
> > > > Why not:
> > > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 27 lines]
>
> where "RICH_EMPLOYEE" refers to a relation.
Yes, under this premise a relation is a synonym for type.

> TroyK
Cimode - 12 Mar 2008 18:33 GMT
> > > > Why not:
> > > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 29 lines]
>
> TroyK
Basically if I write down

1) [MAKE VIP_MEMBER = {RICH_EMPLOYEE}]
or
2) [MAKE VIP_MEMBER = {MEMBER RICH_EMPLOYEE}]

I am defining VIP_MEMBER as having one attribute of type RICH_EMPLOYEE
(named RICH_EMPLOYEE in case 1 or MEMBER_RICH in case 2) while if I
write

[MAKE VIP_MEMBER = [RICH_EMPLOYEE]] I am actually equating the
relation VIP_MEMBER and the relation RICH_EMPLOYEE.  Both are in fact
valid.  It just depends if we are working at relation level or at
attribute level.
TroyK - 13 Mar 2008 22:00 GMT
> > > > > Why not:
> > > > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 46 lines]
>
> - Show quoted text -

I think I'm getting tripped up over whether the declaration is of a
new relation (called VIP_MEMBER that has (a) one attribute that is a
relvar, or (b) one attribute that is a relation.

Is this syntax:
[MAKE VIP_MEMBER = [RICH_EMPLOYEE]]
a view definition, or an assignment?

By the way, I should have prefaced my first response to the thread
with the disclaimer that I'm by no means a language designer, so you
can feel free to take my comments with a grain of salt.

TroyK
Cimode - 13 Mar 2008 22:27 GMT
> > > > > > Why not:
> > > > > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 50 lines]
> new relation (called VIP_MEMBER that has (a) one attribute that is a
> relvar, or (b) one attribute that is a relation.
An un-ary relation is *de facto* is a type.
When using {}, (b) is correct

> Is this syntax:
> [MAKE VIP_MEMBER = [RICH_EMPLOYEE]]
> a view definition, or an assignment?
A relation level assignment.  Not a view.
When running...
[MAKE VIP_MEMBER = [RICH_EMPLOYEE]] I am creating a new relation whose
body is independent from RICH_EMPLOYEE.  As soon as an operation
impacts any of the two bodies, the two relations do not equate
anymore.

As a consequence, if I then run
[MAKE VIP_MEMBER = VIP_MEMBER - {1, 1} ] --> delete
[MAKE RICH_EMPLOYEE = RICH_EMPLOYEE - {1, 2} ]

VIP_MEMBER and  RICH_EMPLOYEE relation are not equal anymore because
only their header and constraint set are equal.

> By the way, I should have prefaced my first response to the thread
> with the disclaimer that I'm by no means a language designer, so you
> can feel free to take my comments with a grain of salt.
I am trying to gain a feedback and perception from all users that can
help me sharpen the language.  You help is appreciated.
> TroyK
Cimode - 12 Mar 2008 20:08 GMT
> > > > Why not:
> > > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 29 lines]
>
> TroyK

Another way to put it would be to say that the system and subsequent
language *de facto* treats an un-ary relation as a type and that the
syntaxic use of [] or {} allows to make the difference.
JOG - 13 Mar 2008 20:30 GMT
> > > Why not:
> > > [MAKE RICH_EMPLOYEE = {EMPLOYEE WITH SALARY > 100000}]
[quoted text clipped - 12 lines]
> [MAKE R2 = R0 UNION R1]
> PRESENT2D [R2]

Few comments for you. Looks sound enough, but do you even need the
word "MAKE" (and why the capitals?). I also fear that the square
brackets around statements will make code look more confusing than
need be - are they really necessary (I understand they inidicate a
"relation expression").

You also mentioned that for constraints you use |constraint| - I'd
personally avoid that, given the use of the bar symbol in logical
disjunction. Whats wrong with good old parentheses used when
necessary?

> does the same thing as
>
> PRESENT2D [{ATTRIBUTE0_1, ATTRIBUTE0_2} UNION {ATTRIBUTE1_1,
> ATTRIBUTE1_2}]

As with TroyK, I found "present2d" to be a bit offputting. In your
initial examples I'd recommend just calling it "present"? Capitals
also give me flashbacks of Cobol PIC's, so I'd personally go lowercase
too ;)

Just my 2p worth.

> It is also about the coherence of the computing model behind.  The
> input of the media layer is necessarily a relation.  The input of the
> logical layer may either be a relation or an attribute set.
Cimode - 13 Mar 2008 21:06 GMT
[Snipped]
> Few comments for you. Looks sound enough, but do you even need the
> word "MAKE"
It is an arbitrary choice.  In initial version, I thought about using
nothing then I thought about using SET and I finally settled on MAKE.
The idea is to create awareness that we are working with a construct
with potential users.
(and why the capitals?).
The MAKE verb is in fact case insensitive.  I posted it this way only
to make it more readable in this thread.

> I also fear that the square
> brackets around statements will make code look more confusing than
> need be - are they really necessary (I understand they inidicate a
> "relation expression").
Well, it's a tough choice but this is what make the expressive power
of the language.  When using brackets, one should think relation.
When one uses {} then we are shifting to attribute based thinking.
That back and forth shifting is what makes easier to shift from
relation level operation to tuple/attribute level operation.  On a
broader context, I had to establish some kind of coherence in the
convention used to jump back and forth from regular thinking to set
oriented.

> You also mentioned that for constraints you use |constraint| - I'd
> personally avoid that, given the use of the bar symbol in logical
> disjunction. Whats wrong with good old parentheses used when
> necessary?
I like the idea.  I may reconsider that.  I thought about reserving
parenthesis to the media layer but that is an arbitrary choice.

> > does the same thing as
>
[quoted text clipped - 3 lines]
> As with TroyK, I found "present2d" to be a bit offputting. In your
> initial examples I'd recommend just calling it "present"
I can see that PRESENT2D seems confusing.  My initial choice for
presenting the tabular format was simply TABLE but then I was afraid
to create an endless source of confusion for programmers priorly
exposed to SQL.
I was also thinking about possible non bidimensional presentations
such OLAP and the opportunity to create OLAP cubes such as

PRESENT3D(A1, A2, A5)[relation] which would be a cube with 3
dimensions.

PRESENT-N-D(A1.......AN)[relation]

Based on your comment I might simply make PRESENT2D a synonym for
PRESENT.
> ? Capitals
Just in this thread.  The verbs used in the language are totally case
insensitive for the compiler.
> also give me flashbacks of Cobol PIC's, so I'd personally go lowercase
> too ;)
I will leave it open to programmers choice.

> Just my 2p worth.
Thank you very much.   That was helpful/
Cimode - 15 Mar 2008 17:22 GMT
<<Capitals also give me flashbacks of Cobol PIC's,>>
I know the pain thrust me.  Even worse, do you remember 88's?  It was
a cheap trick to allow to redefine data structure at run time with no
strings attached.

Last time I coded COBOL, I think my last thought was something like
*They will have to pay me lots of money if they want me to do this all
over again*.
Cimode - 11 Mar 2008 19:31 GMT
> > (snip)
> > SUMMARY
[quoted text clipped - 23 lines]
> PRESENT2D - does the name imply that there will be other n-dimensional
> presentations available (PRESENT3D, e.g.)?
To be quite frank I did not think about multidimensional but my guess
is that nothing should prevent the media layer to allow for instance
the build of OLAP if that's what you have in mind.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.