http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/TableNameFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/TableNameFunction.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/TableNameFunction.java
new file mode 100644
index 0000000..2e38392
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/TableNameFunction.java
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common;
+
+import 
org.apache.polygene.library.sql.generator.grammar.literals.SQLFunctionLiteral;
+
+/**
+ * A table name function serves as a function call when selecting data.
+ *
+ * @author 2011 Stanislav Muhametsin
+ */
+public interface TableNameFunction
+    extends TableName
+{
+    /**
+     * Returns the function to call.
+     *
+     * @return The function to call.
+     */
+    SQLFunctionLiteral getFunction();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/ValueExpression.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/ValueExpression.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/ValueExpression.java
new file mode 100644
index 0000000..de07261
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/ValueExpression.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+
+/**
+ * A common interface for {@link BooleanExpression} and {@link 
NonBooleanExpression}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface ValueExpression
+    extends Typeable<ValueExpression>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/BigInt.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/BigInt.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/BigInt.java
new file mode 100644
index 0000000..a82b1f4
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/BigInt.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code BIGINT} type (typically 64-bit integer).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface BigInt
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Decimal.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Decimal.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Decimal.java
new file mode 100644
index 0000000..d4b441e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Decimal.java
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * <p>
+ * This class represents the {@code DECIMAL} data type, sometimes abbreviated 
as {@code DEC}. The site
+ * http://intelligent-enterprise.informationweek.com/000626/celko.jhtml 
explains difference between {@code NUMERIC} and
+ * {@code DECIMAL}:
+ * </p>
+ * <p>
+ * The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the 
SQL-92 Standard -- DECIMAL(s,p) must be exactly
+ * as precise as declared, while NUMERIC(s,p) must be at least as precise as 
declared.
+ * </p>
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Decimal
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the precision (first integer) for this {@code DECIMAL}.
+     *
+     * @return The precision for this {@code DECIMAL}.
+     */
+    Integer getPrecision();
+
+    /**
+     * Returns the scale (second integer) for this {@code DECIMAL}.
+     *
+     * @return The precision for this {@code DECIMAL}.
+     */
+    Integer getScale();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/DoublePrecision.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/DoublePrecision.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/DoublePrecision.java
new file mode 100644
index 0000000..431b75c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/DoublePrecision.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents {@code DOUBLE PRECISION} data type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface DoublePrecision
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/IntervalDataType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/IntervalDataType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/IntervalDataType.java
new file mode 100644
index 0000000..fb9b93e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/IntervalDataType.java
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class contains all the types for fields in {@code INTERVAL} data type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class IntervalDataType
+{
+    public static final IntervalDataType YEAR = new IntervalDataType();
+
+    public static final IntervalDataType MONTH = new IntervalDataType();
+
+    public static final IntervalDataType DAY = new IntervalDataType();
+
+    public static final IntervalDataType HOUR = new IntervalDataType();
+
+    public static final IntervalDataType MINUTE = new IntervalDataType();
+
+    public static final IntervalDataType SECOND = new IntervalDataType();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Numeric.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Numeric.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Numeric.java
new file mode 100644
index 0000000..842e1be
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Numeric.java
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * <p>
+ * This class represents the {@code NUMERIC} type. The site
+ * http://intelligent-enterprise.informationweek.com/000626/celko.jhtml 
explains difference between {@code NUMERIC} and
+ * {@code DECIMAL}:
+ * </p>
+ * <p>
+ * The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the 
SQL-92 Standard -- DECIMAL(s,p) must be exactly
+ * as precise as declared, while NUMERIC(s,p) must be at least as precise as 
declared.
+ * </p>
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Numeric
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the precision (first integer) for this {@code NUMERIC}.
+     *
+     * @return The precision for this {@code NUMERIC}.
+     */
+    Integer getPrecision();
+
+    /**
+     * Returns the scale (second integer) for this {@code NUMERIC}.
+     *
+     * @return The precision for this {@code NUMERIC}.
+     */
+    Integer getScale();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/ParametrizableDataType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/ParametrizableDataType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/ParametrizableDataType.java
new file mode 100644
index 0000000..b056181
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/ParametrizableDataType.java
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This is marker interface for SQL data types which may be parametrized 
(like, {@code DECIMAL} or {@code VARCHAR}).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface ParametrizableDataType
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Real.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Real.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Real.java
new file mode 100644
index 0000000..3a73cae
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/Real.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code REAL} data type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Real
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLBoolean.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLBoolean.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLBoolean.java
new file mode 100644
index 0000000..870aff6
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLBoolean.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code BOOLEAN} type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLBoolean
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLChar.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLChar.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLChar.java
new file mode 100644
index 0000000..82ec6db
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLChar.java
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents {@code CHARACTER} and {@code CHARACTER VARYING} data 
types, typically abbreviated as
+ * {@code CHAR} and {@code VARCHAR}, respectively.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLChar
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns {@code true} if this is {@code CHARACTER VARYING}; {@code false 
otherwise}.
+     *
+     * @return {@code true} if this is {@code CHARACTER VARYING}; {@code false 
otherwise}.
+     */
+    Boolean isVarying();
+
+    /**
+     * Returns the length specification for this {@code CHARACTER} or {@code 
CHARACTER VARYING}. Returns {@code null} if
+     * none specified.
+     *
+     * @return The length for this {@code CHARACTER} or {@code CHARACTER 
VARYING}.
+     */
+    Integer getLength();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDataType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDataType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDataType.java
new file mode 100644
index 0000000..9df446a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDataType.java
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is common interface for all SQL data types. The data types provided in 
this project cover most of of SQL
+ * predefined types, however each vendor may extend these with their own 
custom types.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLDataType
+    extends Typeable<SQLDataType>
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDate.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDate.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDate.java
new file mode 100644
index 0000000..eae5f4d
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLDate.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code DATE} data type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLDate
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLFloat.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLFloat.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLFloat.java
new file mode 100644
index 0000000..2b89cc1
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLFloat.java
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code FLOAT} type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLFloat
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the precision for this {@code FLOAT}.
+     *
+     * @return The precision for this {@code FLOAT}.
+     */
+    Integer getPrecision();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInteger.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInteger.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInteger.java
new file mode 100644
index 0000000..951f5c0
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInteger.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code INTEGER} type, sometimes abbreviated as 
{@code INT} (typically 32-bit integer).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLInteger
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInterval.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInterval.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInterval.java
new file mode 100644
index 0000000..5f35b90
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLInterval.java
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code INTEGER} type, sometimes abbreviated as 
{@code INT} (typically 32-bit integer).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLInterval
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the start field type for this {@code INTERVAL}.
+     *
+     * @return The start field type for this {@code INTERVAL}.
+     */
+    IntervalDataType getStartField();
+
+    /**
+     * Return the start field precision for this {@code INTERVAL}. May be 
{@code null} if none specified.
+     *
+     * @return The start field precision for this {@code INTERVAL}.
+     */
+    Integer getStartFieldPrecision();
+
+    /**
+     * Returns the end field precision for this {@code INTERVAL}. Will always 
be {@code null} for single datetime field
+     * intervals.
+     *
+     * @return The end field precision for this {@code INTERVAL}.
+     */
+    IntervalDataType getEndField();
+
+    /**
+     * Returns the fraction seconds precision for this {@code INTERVAL}. Will 
always be {@code null} if the end field
+     * type is not {@link IntervalDataType#SECOND}, or if this is single 
datetime field interval, and its start type is
+     * not {@link IntervalDataType#SECOND}.
+     *
+     * @return The fraction seconds precision for this {@code INTERVAL}.
+     */
+    Integer getSecondFracs();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTime.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTime.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTime.java
new file mode 100644
index 0000000..3f11b38
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTime.java
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents {@code TIME} data type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SQLTime
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the precision for this {@code TIME}. May be {@code null}.
+     *
+     * @return The precision for this {@code TIME}.
+     */
+    Integer getPrecision();
+
+    /**
+     * Returns whether the {@code TIME} should be with time zone. May be 
{@code null} if no choice specified.
+     *
+     * @return
+     */
+    Boolean isWithTimeZone();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTimeStamp.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTimeStamp.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTimeStamp.java
new file mode 100644
index 0000000..2a01623
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SQLTimeStamp.java
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * @author Stanislav Muhametsin
+ */
+public interface SQLTimeStamp
+    extends SQLDataType, ParametrizableDataType
+{
+
+    /**
+     * Returns the precision for this {@code TIMESTAMP}. May be {@code null}.
+     *
+     * @return The precision for this {@code TIMESTAMP}.
+     */
+    Integer getPrecision();
+
+    /**
+     * Returns whether the {@code TIMESTAMP} should be with time zone. May be 
{@code null} if no choice specified.
+     *
+     * @return
+     */
+    Boolean isWithTimeZone();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SmallInt.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SmallInt.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SmallInt.java
new file mode 100644
index 0000000..2fd83e5
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/SmallInt.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+/**
+ * This class represents the {@code SMALLINT} type (typically 16-bit integer).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SmallInt
+    extends SQLDataType
+{
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/UserDefinedType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/UserDefinedType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/UserDefinedType.java
new file mode 100644
index 0000000..cded18a
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/UserDefinedType.java
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
+
+import 
org.apache.polygene.library.sql.generator.grammar.factories.DataTypeFactory;
+
+/**
+ * This is a general way of handling any user-created or otherwise custom 
type. It is advisable to always use the
+ * methods provided by your vendor's data type factory (most likely 
sub-interface of {@link DataTypeFactory}) instead of
+ * using this interface. However, when data type is dynamically created, it is 
quite a must to use this type.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface UserDefinedType
+    extends SQLDataType
+{
+
+    String getTextualRepresentation();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/package-info.java
new file mode 100644
index 0000000..08e9d95
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/package-info.java
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+/**
+ * This is the package containing support for (most)pre-defined SQL data types.
+ */
+package org.apache.polygene.library.sql.generator.grammar.common.datatypes;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/pgsql/Text.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/pgsql/Text.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/pgsql/Text.java
new file mode 100644
index 0000000..01ef739
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/datatypes/pgsql/Text.java
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.pgsql;
+
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SQLDataType;
+
+/**
+ * This data type represents the {@code TEXT} data type in PostgreSQL.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface Text
+    extends SQLDataType
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/package-info.java
new file mode 100644
index 0000000..1581cb0
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/common/package-info.java
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+/**
+ * This package contains interfaces and classes common for most parts of SQL 
generator.
+ */
+package org.apache.polygene.library.sql.generator.grammar.common;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaDefinition.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaDefinition.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaDefinition.java
new file mode 100644
index 0000000..ede7a43
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaDefinition.java
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.schema;
+
+import java.util.List;
+import 
org.apache.polygene.library.sql.generator.grammar.common.SchemaDefinitionStatement;
+
+/**
+ * This syntax element represents the {@code CREATE SCHEMA} statement.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface SchemaDefinition
+    extends SchemaDefinitionStatement
+{
+
+    /**
+     * Returns the name of the schema to be created.
+     *
+     * @return The name of the schema to be created.
+     */
+    String getSchemaName();
+
+    /**
+     * Returns the character set for this schema. May be {@code null} if none 
specified.
+     *
+     * @return The character set for this schema. May be {@code null} if none 
specified.
+     */
+    String getSchemaCharset();
+
+    /**
+     * Returns any additional elements for this schema. May be empty if none 
are present.
+     *
+     * @return Any additional elements for this schema. May be empty if none 
are present.
+     */
+    List<SchemaElement> getSchemaElements();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaElement.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaElement.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaElement.java
new file mode 100644
index 0000000..24a895e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/SchemaElement.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.schema;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is a common interface for all definitions that may be present in 
schema definition.
+ *
+ * @author Stanislav Muhametsin
+ * @see SchemaDefinition
+ */
+public interface SchemaElement
+{
+
+    Typeable<?> asTypeable();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/package-info.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/package-info.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/package-info.java
new file mode 100644
index 0000000..6fe4d50
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/schema/package-info.java
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+/**
+ * This package contains syntax interfaces for {@code CREATE SCHEMA} statement.
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.schema;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/AutoGenerationPolicy.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/AutoGenerationPolicy.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/AutoGenerationPolicy.java
new file mode 100644
index 0000000..44576e7
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/AutoGenerationPolicy.java
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This class defines the policy for auto-generated columns ({@code GENERATED 
<strategy> AS IDENTITY}.
+ *
+ * @author Stanislav Muhametsin
+ * @see ColumnDefinition
+ */
+public final class AutoGenerationPolicy
+{
+    private final String _policyName;
+
+    public AutoGenerationPolicy( String policyName )
+    {
+        this._policyName = policyName;
+    }
+
+    /**
+     * Represents the {@code GENERATED ALWAYS AS IDENTITY} auto generation 
policy.
+     */
+    public static final AutoGenerationPolicy ALWAYS = new 
AutoGenerationPolicy( "ALWAYS" );
+
+    /**
+     * Represents the {@code GENERATED BY DEFAULT AS IDENTITY} auto generation 
policy.
+     */
+    public static final AutoGenerationPolicy BY_DEFAULT = new 
AutoGenerationPolicy( "BY DEFAULT" );
+
+    @Override
+    public String toString()
+    {
+        return this._policyName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/CheckConstraint.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/CheckConstraint.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/CheckConstraint.java
new file mode 100644
index 0000000..febef93
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/CheckConstraint.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import 
org.apache.polygene.library.sql.generator.grammar.booleans.BooleanExpression;
+
+/**
+ * This syntax element represents the {@code CHECK( ... )} constraint in table 
definition.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableDefinition
+ */
+public interface CheckConstraint
+    extends TableConstraint
+{
+    BooleanExpression getCheckCondition();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ColumnDefinition.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ColumnDefinition.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ColumnDefinition.java
new file mode 100644
index 0000000..c13fe32
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ColumnDefinition.java
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import 
org.apache.polygene.library.sql.generator.grammar.common.datatypes.SQLDataType;
+
+/**
+ * This syntax element represents the column definition of the table 
definition statement.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableDefinition
+ */
+public interface ColumnDefinition
+    extends TableElement
+{
+
+    /**
+     * Returns the name of this column.
+     *
+     * @return The name of this column.
+     */
+    String getColumnName();
+
+    /**
+     * Returns the data type of this column.
+     *
+     * @return The data type of this column.
+     */
+    SQLDataType getDataType();
+
+    /**
+     * Returns the default clause for this column. May be {@code null} if no 
default value is defined.
+     *
+     * @return The default clause for this column. May be {@code null} if no 
default value is defined.
+     */
+    String getDefault();
+
+    /**
+     * Returns {@code true} if this column may have {@code NULL} values, 
otherwise (when {@code NOT NULL} constraints is
+     * present) returns {@code false}.
+     *
+     * @return {@code true} if this column may have {@code NULL} values; 
{@code false} otherwise.
+     */
+    Boolean mayBeNull();
+
+    /**
+     * Returns the auto generation policy for this column. May be {@code null} 
if no auto generation policy exists for
+     * this column.
+     *
+     * @return Auto generation policy for this column, or {@code null} if the 
column is not auto-generated.
+     */
+    AutoGenerationPolicy getAutoGenerationPolicy();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ConstraintCharacteristics.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ConstraintCharacteristics.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ConstraintCharacteristics.java
new file mode 100644
index 0000000..90d7638
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ConstraintCharacteristics.java
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This enum represents three different policies for checking constraints 
time. These policies are
+ * {@link #INITIALLY_IMMEDIATE_DEFERRABLE}, {@link 
#INITIALLY_DEFERRED_DEFERRABLE}, and {@link #NOT_DEFERRABLE}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class ConstraintCharacteristics
+{
+    /**
+     * Represents the {@code INITIALLY IMMEDIATE DEFERRABLE} constraint time 
check.
+     */
+    public static final ConstraintCharacteristics 
INITIALLY_IMMEDIATE_DEFERRABLE = new ConstraintCharacteristics();
+
+    /**
+     * Represents the {@code INITIALLY DEFERRED DEFERRABLE} constraint time 
check.
+     */
+    public static final ConstraintCharacteristics 
INITIALLY_DEFERRED_DEFERRABLE = new ConstraintCharacteristics();
+
+    /**
+     * Represents the {@code [INITIALLY IMMEDIATE] NOT DEFERRABLE} constraint 
time check.
+     */
+    public static final ConstraintCharacteristics NOT_DEFERRABLE = new 
ConstraintCharacteristics();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ForeignKeyConstraint.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ForeignKeyConstraint.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ForeignKeyConstraint.java
new file mode 100644
index 0000000..55acc2c
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ForeignKeyConstraint.java
@@ -0,0 +1,79 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import org.apache.polygene.library.sql.generator.grammar.common.ColumnNameList;
+import 
org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+
+/**
+ * This syntax element represents the {@code FOREIGN KEY(col1, col2, ...) ...} 
table constraint in table definition.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableConstraint
+ * @see TableDefinition
+ */
+public interface ForeignKeyConstraint
+    extends TableConstraint
+{
+
+    /**
+     * Returns the list of column names in this table.
+     *
+     * @return The list of column names in this table.
+     */
+    ColumnNameList getSourceColumns();
+
+    /**
+     * Returns the name of the table where the columns in this table are 
referencing to.
+     *
+     * @return The name of the table where the columns in this table are 
referencing to.
+     */
+    TableNameDirect getTargetTableName();
+
+    /**
+     * Returns the list of column names in target table. Will be {@code null} 
if none specified.
+     *
+     * @return The list of column names in target table. Will be {@code null} 
if none specified.
+     */
+    ColumnNameList getTargetColumns();
+
+    /**
+     * Returns the match type for this foreign key. May be {@code null} if no 
match type is specified.
+     *
+     * @return The match type for this foreign key. May be {@code null} if no 
match type is specified.
+     */
+    MatchType getMatchType();
+
+    /**
+     * Returns the referential action of updating the rows. May be {@code 
null} if none specified.
+     *
+     * @return The referential action of updating the rows. May be {@code 
null} if none specified.
+     * @see ReferentialAction
+     */
+    ReferentialAction getOnUpdate();
+
+    /**
+     * Returns the referential action of deleting the rows. May be {@code 
null} if none specified.
+     *
+     * @return The referential action of deleting the rows. May be {@code 
null} if none specified.
+     * @see ReferentialAction
+     */
+    ReferentialAction getOnDelete();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/LikeClause.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/LikeClause.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/LikeClause.java
new file mode 100644
index 0000000..2ef51e9
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/LikeClause.java
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import 
org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+
+/**
+ * This syntax element represents the {@code LIKE
+ * <table name>} clause in table definition.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableDefinition
+ */
+public interface LikeClause
+    extends TableElement
+{
+
+    /**
+     * Returns the name of the table for this {@code LIKE} clause.
+     *
+     * @return The name of the table for this {@code LIKE} clause.
+     */
+    TableNameDirect getTableName();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/MatchType.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/MatchType.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/MatchType.java
new file mode 100644
index 0000000..00c8183
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/MatchType.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This enum represents the three different ways of matching foreign keys. May 
be {@link #FULL}, {@link #PARTIAL}, or
+ * {@link #SIMPLE}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class MatchType
+{
+
+    /**
+     * Represents the full match ({@code MATCH FULL}).
+     */
+    public static final MatchType FULL = new MatchType();
+
+    /**
+     * Represents the partial match ({@code MATCH PARTIAL}).
+     */
+    public static final MatchType PARTIAL = new MatchType();
+
+    /**
+     * Represents the simple match ({@code MATCH SIMPLE}).
+     */
+    public static final MatchType SIMPLE = new MatchType();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ReferentialAction.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ReferentialAction.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ReferentialAction.java
new file mode 100644
index 0000000..f1f056d
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/ReferentialAction.java
@@ -0,0 +1,57 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This enum represents the five referential actions of SQL. These are {@link 
#CASCADE}, {@link #SET_NULL},
+ * {@link #SET_DEFAULT}, {@link #RESTRICT}, and {@link #NO_ACTION}.
+ *
+ * @author Stanislav Muhametsin
+ */
+public final class ReferentialAction
+{
+
+    /**
+     * Represents the cascading policy ({@code CASCADE}.
+     */
+    public static final ReferentialAction CASCADE = new ReferentialAction();
+
+    /**
+     * Represents the policy, which sets the value as {@code NULL} ({@code SET 
NULL}.
+     */
+    public static final ReferentialAction SET_NULL = new ReferentialAction();
+
+    /**
+     * Represents the policy, which sets the value as default ({@code SET 
DEFAULT}.
+     */
+    public static final ReferentialAction SET_DEFAULT = new 
ReferentialAction();
+
+    /**
+     * Represents the policy, which checks the integrity <b>before</b> {@code 
UPDATE} or {@code DELETE} statement, and
+     * the statement will not be executed if it violates integrity.
+     */
+    public static final ReferentialAction RESTRICT = new ReferentialAction();
+
+    /**
+     * Represents the policy, which checks the integrity <b>after</b> {@code 
UPDATE} or {@code DELETE} statement, and
+     * the statement will not be executed if it violates integrity.
+     */
+    public static final ReferentialAction NO_ACTION = new ReferentialAction();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableCommitAction.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableCommitAction.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableCommitAction.java
new file mode 100644
index 0000000..c232fa5
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableCommitAction.java
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This enum is for table commit action ({@code ON COMMIT} ...) in table 
definition. The commit action may be either
+ * {@link #ON_COMMIT_PRESERVE_ROWS} or {@link #ON_COMMIT_DELETE_ROWS}.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableDefinition
+ */
+public final class TableCommitAction
+{
+
+    /**
+     * The commit action for {@code ON COMMIT PRESERVE ROWS}.
+     */
+    public static final TableCommitAction ON_COMMIT_PRESERVE_ROWS = new 
TableCommitAction();
+
+    /**
+     * The commit action for {@code ON COMMIT DELETE ROWS}.
+     */
+    public static final TableCommitAction ON_COMMIT_DELETE_ROWS = new 
TableCommitAction();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraint.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraint.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraint.java
new file mode 100644
index 0000000..1f0c30e
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraint.java
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is a common interface for all table constraints.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableConstraintDefinition
+ * @see TableDefinition
+ */
+public interface TableConstraint
+    extends Typeable<TableConstraint>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraintDefinition.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraintDefinition.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraintDefinition.java
new file mode 100644
index 0000000..b7e6232
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableConstraintDefinition.java
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+/**
+ * This syntax element represents the constraint definition for a table.
+ *
+ * @author Stanislav Muhametsin
+ * @see TableElement
+ * @see TableDefinition
+ * @see TableConstraint
+ */
+public interface TableConstraintDefinition
+    extends TableElement
+{
+
+    /**
+     * Returns the optional name for this constraint. Will be {@code null} if 
no name defined for this constraint.
+     *
+     * @return The optional name for this constraint. Will be {@code null} if 
no name defined for this constraint.
+     */
+    String getConstraintName();
+
+    /**
+     * Returns the constraint characteristics for this constraint. Will be 
{@code null} if no characteristics defined.
+     *
+     * @return The constraint characteristics for this constraint. Will be 
{@code null} if no characteristics defined.
+     * @see ConstraintCharacteristics
+     */
+    ConstraintCharacteristics getCharacteristics();
+
+    /**
+     * Returns the actual table constraint.
+     *
+     * @return The actual table constraint.
+     */
+    TableConstraint getConstraint();
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableContentsSource.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableContentsSource.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableContentsSource.java
new file mode 100644
index 0000000..d129fc9
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableContentsSource.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import org.apache.polygene.library.sql.generator.Typeable;
+
+/**
+ * This is a common interface for table source in table definition (in most 
cases, it is a comma-separated list of
+ * column definitions).
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableContentsSource
+    extends Typeable<TableContentsSource>
+{
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a36086b6/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableDefinition.java
----------------------------------------------------------------------
diff --git 
a/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableDefinition.java
 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableDefinition.java
new file mode 100644
index 0000000..37e90e5
--- /dev/null
+++ 
b/libraries/sql-generator/src/main/java/org/apache/polygene/library/sql/generator/grammar/definition/table/TableDefinition.java
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.sql.generator.grammar.definition.table;
+
+import 
org.apache.polygene.library.sql.generator.grammar.common.SchemaDefinitionStatement;
+import org.apache.polygene.library.sql.generator.grammar.common.TableName;
+import 
org.apache.polygene.library.sql.generator.grammar.common.TableNameDirect;
+import 
org.apache.polygene.library.sql.generator.grammar.definition.schema.SchemaElement;
+
+/**
+ * This syntax element represents the table definition ({@code CREATE TABLE }) 
statement.
+ *
+ * @author Stanislav Muhametsin
+ */
+public interface TableDefinition
+    extends SchemaDefinitionStatement, SchemaElement
+{
+    /**
+     * Returns the table scope for this table. May be {@code null} if no scope 
defined.
+     *
+     * @return The table scope for this table. May be {@code null} if no scope 
defined.
+     * @see TableScope
+     */
+    TableScope getTableScope();
+
+    /**
+     * Returns the name for this table.
+     *
+     * @return The name for this table.
+     * @see TableName
+     */
+    TableNameDirect getTableName();
+
+    /**
+     * Returns the commit action for this table. May be {@code null} if no 
commit action defined.
+     *
+     * @return The commit action for this table. May be {@code null} if no 
commit action defined.
+     * @see TableCommitAction
+     */
+    TableCommitAction getCommitAction();
+
+    /**
+     * Returns the actual body of this table definition. Usually is a list of 
column definitions and constraints.
+     *
+     * @return The actual body of this table definition.
+     */
+    TableContentsSource getContents();
+}

Reply via email to