Introducing a post-relational database for .NET

Wrapping Up

To view the inserted objects, execute "SELECT * FROM Employee" for example:

Execute SELECT statement

When you select from the class Employee, the query returns objects from both Employee and Manager since Manager is inheriting from Employee . However, the result table does not include the properties specific to Manager, e.g., Title , because the attribute Title is not visible from the class Employee .

You can define SQL methods for classes. The syntax follows SQL PSM (Persistent Stored Module). For example, let us define an instance method Age() that returns the age of an employee:

CREATE METHOD Age()
RETURNS INTEGER
FOR Employee
BEGIN
  RETURN EXTRACT(YEAR FROM CURRENT_DATE) - EXTRACT(YEAR FROM SELF.BirthDate);
END;

Execute the statement in the SQL Query Analyzer window, and then try the next SELECT query:

SELECT * FROM Employee emp WHERE emp.Age() > 40 ;

The Age() method works for both Employee and Manager, of course. You can override the method for Manager, and enjoy the polymorphic behavior just as you do with .NET.

Next Article

In this article, I showed a quick and brief introduction to SQL programming with Matisse, which shows object features like inheritance and relationships. In the following articles, I will show more details for each topic and discuss the technical advantages and disadvantages.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”