Introduction Matisse
- Post-relational database for .NET Database Part 1
Introduction
When I started to contact the database for .NET, I found that there are many choices in addition to some databases, such as SQL Server, MySQL, there are many options. Matisse is one of them, it is a post-translational database (POST-RELATIONAL DATABASE).
Why choose Matisse? That's because it is what I know, the only Database for .NET is expanded, all of the object performance and native .NET supported. Its main performance includes user-defined types, inheritance, polymorphism, and simple data models. In the past two years, I have acquired Matisse's actual work knowledge in multiple .NET projects that need complex data models.
If someone wants to find a detailed article, it is possible to deeply compare the mainstream relational databases and other products. I haven't seen a simple, gradual tutorial, can help developers who wish to touch the new generation of databases. Therefore, I decided to release a series of short-text to fill this gap, this is the first article.
This first article is mainly to make SQL programming with Matisse. In the next article, you will introduce how to develop database applications using .NET and ASP.NET.
installation
Install Matisse is very simple and fast. Go to the Matisse download site http://www.matisse.com/developers/downloads/, and download the following two files in the "Matisse DBMS 7.0.x" area:
1. Intel - MS Windows (File Name is Matisse70x.exe)
2. .net binding (File name is MatissedotNet70X.exe)
The first file is installed database service, manages and development tools, and a universal client link library, which can be shared for different languages, such as C #, VB.NET, etc. The second file contains a .NET's assembly (Assembly), which provides object permanent service and a native ADO.NET provider.
Translator Note: Here, I translate Native ADO.NET DATA Provider as the native ADO.NET provider.
To install Matisse, you need to have permissions of the Windows System Administrator Level (Administrator), the basic configuration of the machine: Windows NT, 2000, or XP, 64MB of memory, and 100MB hard disk space. First, execute the Matisse70x.exe file, follow the guide to the installation wizard, when the installation type occurs, remember to select "Typical / Full" and the installation process will end within a few minutes. Next, execute the MatissedotNet70X.exe file, install the .NET interface, select the same directory as the previous installation.
You should take a look at the following documents before you start using it:
1. Discovering Matisse Enterprise Manager (from readme.html)
2. Building Reusable Components with SQL PSM (from readme.html)
3. Getting started with matisse
You can also find some guidelines for programming, database management, and installation in the following URLs:
Http://www.matisse.com/developers/Documentation/.
If there is a Rational Rose modeling tool, you can also download Matisse Rose Link (MatisSoldselink70x.exe). It allows you to use UML to define and maintain database schema. Remember, you can also run your Database server on Linux, then publish your .NET application on Windows. You only need to download the Linux version of Matisse (Matisse-7.0-x.i386.rpm) and install it with RPM. If you use RedHat 8, you need to modify the environment variable RPM_INSTALL_PREFIX as / usr / local / matisse before running RMP.
> rpm -ihv matisse-7.0-x.i386.rpm
What can you do with Matisse Enterprise Manager?
Let us look at the interesting features of Enterprise Manager before starting to write a demo.
1. You can browse the classes, properties, relationships, and SQL methods in a database like other toll software. One of the interesting features, you can see all properties of a class (such as attributes, relationships, and methods), and the properties of the subclass. This way, this feature is becoming useful when you write a SQL declaration in the class, because you don't have to switch between the parent class and the subclass to find an attribute.
2. Data Pour (CSV)
Using the CSV (COMMA-SEPARATED) file, you can pour the data from the relational database. When you pour the data from the CSV file, each line in the file is stored as a data object. After all CSV files are inserted, you need to define an XRD file (XML Relationship Definition) that describes link relationships between different objects in the database. Subsequently based on the description in your UML, the objects in the database are integrated into a meaningful semantic network. The relationship between objects will provide a significant performance optimization when SQL query.
Simple demo
In this article, I will show a simple demo application to show how to use SQL to define a Schema and operational data objects. In the next article, we will discuss more in-depth discussions.
First, you need to open a database. Execute Enterprise Manager, select a database, then click the Start menu. After a few seconds, the database will be started.
In this demo program, we will use the project management mode. These are defined three classes: Project, Employee, and Manager. Its relationship is as follows:
If there is Rational Rose, it can be very convenient to pour the UML map. Select Tools -> Matisse -> EXPORT to Database ... menu:
If there is Rational Rose, you can use SQL DDL or ODL (Object Definition Language). The following DDL statements and the previous UML map are equivalent.
CREATE TABLE PROJECT
ProjectName String,
BUDGET NUMERIC (19, 2),
MEMBERS References (Employee)
Cardinality (1, -1)
Inverse Employee.Worksin,
Managedby References (Manager)
Cardinality (1, 1)
Inverse Manager.Manages
);
CREATE TABLE EMPLOYEE
Name String,
Birthdate date,
Worksin References (Project)
Inverse Project.members
);
Create Table Manager Under Employee (Title String,
Manages References (Project)
Inverse Project.managedby
);
To perform the DDL Statement above, copy to the SQL Query Analyzer window, execute.
At this point, you should see the advantages of using Matisse to model the database mode! You don't need to change your mode, all the relationships between all classes and other containers have been retained in the Schema of the database. This is a great advantage for maintaining and expanding applications.
Now we can build an object in the database. Perform the following code in the SQL Query Analyzer window:
INSERT INTO Employee (Name, Birthdate)
VALUES ('John Venus', Date '1955-10-01')
Returning INTO EMP1;
INSERT INTO Employee (Name, Birthdate)
VALUES ('Amy Mars', Date '1965-09-25')
Returning INTO EMP2;
Insert Into Manager (Name, Birthdate, Title)
VALUES ('Ken Jupiter', Date '1952-12-15', 'Director')
Returning INTO MGR1;
INSERT INTO Project (Projectname, Budget, Managedby, MEMBERS)
VALUES ('Campaign Spring 04', 1000.00, MGR1, Selection);
The above code creates two Employee objects, a Manager object, a Project object. This two employee objects are then joined as a member to the project object, while the manager object is joined as a manager.
To check the inserted object, perform the "SELECT * from Employee" statement
When you look up according to Employee, the query returns two kinds of objects - Employee and Manager. Because they all inherit to class Employee. However, some attributes in the Manager object, such as Title, are not displayed in the results table, because these attributes are not included in class EMPLOYEE, but in their subclasses.
You can define the SQL method of the class. The syntax follows the SQL PSM (Persistent Stored Module). For example, let us define an instance method AGE (), which returns the age of the employee.
Create Method Age ()
Returns integer
For Employee
Begin
Return Extract (Year from current_date) - Extract (Year from self.birthdate);
END;
Perform the above statement in the SQL Query Analyzer window and try the following query statement.
Select * from Employee Emp where Emp.Age ()> 40;
Age () This method is defined in Employee, and its sub-class Manager has inherited this method. Of course, you can also use it like .NET, such as writing this method in the Manager class, or uses its polymorphism characteristic.
Next article