Multi-Model QuickStart

15 minutes
estimated time of completion.
InterSystems IRIS™ data platform provides a multi-model architecture that allows you to use the data model that best fits each task in your application — relational, object, or even direct/native access — all accessible through the language of your choice. Multi-model features available in InterSystems IRIS include:
  • Industry-standard APIs for SQL and object access
  • An API to store data in a custom optimized data structure
  • A reusable database connection that supports using the best data model for each task
  • APIs for your language of choice (including Java, .NET, and ObjectScript)
  • An underlying consistent structure avoiding data duplication
Watch the short video, then try the exercise below using one of the languages listed.
Note
If you don’t have InterSystems IRIS set up yet, get a free development sandbox here.

Try it: Java

With Java, you can interact with InterSystems IRIS relationally (with JDBC), using objects (with XEP or Hibernate), or natively (with the Native API). For this exercise, you can use your favorite IDE that supports Java. One common example is Eclipse. You must also have JDK8 installed. In the steps below, you will create a set of airport data as objects, retrieve that data via SQL, and then natively access custom data structures to store route information.

Setup

  1. Get the sample code:
    1. If you are using the Learning Labs sandbox, you already have the GitHub repo cloned and ready to go.
    2. If you are using Community Edition (on a public cloud or a local Docker install), in your terminal, type: iris load https://github.com/intersystems/quickstarts-multimodel-java
    3. Otherwise, clone this repo: https://github.com/intersystems/quickstarts-multimodel-javaYou should now have three new classes: Demo.Airport.java, Demo.Location.java, and multimodelQS.java.
  2. Correct the credentials:
    1. If you are using the Learning Labs sandbox, you are all set.
    2. If you are using Community Edition (on a public cloud or a local Docker install), make sure to use the username and password for the InterSystems IRIS instance (rather than the credentials of the container.)
    3. Otherwise, modify the variables for IP and password (for InterSystems IRIS) in multimodelQS.java to connect to your instance of InterSystems IRIS. Port and username should be OK but verify these are correct as well.

Use objects and SQL side by side

  1. Run multimodelQS.java which executes the populateAirports() and getAirports() methods.
  2. Inspect the output and code. The first method — populateAirports() — populates five objects and saves them to the database, while the second method — getAirports() — runs an SQL query and returns all airports, printing them to the screen. Using InterSystems IRIS, you can interact with data using either objects or SQL based on the task, optimizing both developer time and application performance.

Create a custom data structure, optimizing development time and performance

In the case where you need to answer a question you did not expect when you built the database, refactoring a relational-only database could be expensive and complicated. With InterSystems IRIS, you may choose to natively store data in a custom data structure, allowing you to modify the structure to fit your specific data and easily handle new data that was not part of your initial schema or class design.
  1. Two other methods — StoreAirfare() and CheckAirfare() — have been created to store route information to InterSystems IRIS and print if a particular route exists. Uncomment the lines that calls StoreAirfare() and CheckAirfare() to see how they work:
    // StoreAirfare(irisNative); 
    // CheckAirfare(irisNative);
  2. To test this, run the code and enter in values to see if there are routes from BOS to AUS. You should find there are routes available. You can run it again and try BOS to LAX, which should return no available routes.

Try it: .NET

With .NET, you can interact with InterSystems IRIS relationally (with ADO.NET), using objects (with XEP or Entity Framework), or natively (with the Native API). For this exercise, you can use your favorite IDE that supports .NET. This sample works best with Microsoft Visual Studio. In the steps below, you will create a set of airport data as objects, retrieve that data via SQL, and then natively access custom data structures to store route information.

Setup

  1. Get the sample .NET code:
    1. If you are using the Learning Labs sandbox, you already have the GitHub repo cloned and ready to go.
    2. If you are using Community Edition (on a public cloud or a local Docker install), in your terminal type: iris load https://github.com/intersystems/quickstarts-multimodel-dotnet
    3. Otherwise, clone this repo: https://github.com/intersystems/quickstarts-multimodel-dotnet. You should now have three new classes: Demo.Airport.cs, Demo.Location.cs, and multimodelQS.cs.
  2. Correct the credentials:
    1. If you are using the Learning Labs sandbox, you are all set.
    2. If you are using Community Edition (on a public cloud or a local Docker install),make sure to use the username and password for the InterSystems IRIS instance (rather than the credentials of the container.)
    3. Otherwise, modify the variables for IP and password (for InterSystems IRIS) in multimodelQS.cs to connect to your instance of InterSystems IRIS. Port and username should be OK but verify these are correct as well.

Use objects and SQL side by side

  1. Run multimodelQS.cs which executes the populateAirports() and getAirports() methods.
  2. Inspect the output and code. The first method — populateAirports() — populates five objects and saves them to the database, while the second method — getAirports() — runs an SQL query and returns all airports, printing them to the screen. Using InterSystems IRIS, you can interact with data using either objects or SQL based on the task, optimizing both developer time and application performance.

Create a custom data structure, optimizing development time and performance

In the case where you need to answer a question you did not expect when you built the database, refactoring a relational-only database could be expensive and complicated. With InterSystems IRIS, you may choose to natively store data in a custom data structure, allowing you to modify the structure to fit your specific data and easily handle new data that was not part of your initial schema or class design.
  1. Two other methods — StoreAirfare() and CheckAirfare() — have been created to store route information to InterSystems IRIS and print if a particular route exists. Uncomment the lines that call StoreAirfare() and CheckAirfare() to see how they work:
    // StoreAirfare(irisNative); 
    // CheckAirfare(irisNative);
  2. To test this, run the code and enter in values to see if there are routes from BOS to AUS. You should find there are routes available. You can run it again and try BOS to LAX, which should return no available routes.

Try it: Python

With Python, you can interact with InterSystems IRIS relationally (with PyODBC) or natively (with the Native API). For this exercise, you can use your favorite IDE that supports Python, such as PyCharm. In the steps below, you will create a set of airport data and retrieve that data via SQL, and then natively access custom data structures to store route information.

Setup

  1. Get the sample Python code:
    1. If you are using the Learning Labs sandbox, you already have the GitHub repo cloned and ready to go.
    2. If you are using Community Edition (on a public cloud or a local Docker install), in your terminal type: iris load https://github.com/intersystems/quickstarts-multimodel-python
    3. Otherwise, clone this repo: https://github.com/intersystems/quickstarts-multimodel-python. You should now a Python file: multimodelQS.py.
  2. Correct the credentials:
    1. If you are using the Learning Labs sandbox, you are all set.
    2. If you are using Community Edition (on a public cloud or a local Docker install), make sure to use the username and password for the InterSystems IRIS instance (rather than the credentials of the container.)
    3. Otherwise, modify the variables for IP and password (for InterSystems IRIS) in multimodelQS.py to connect to your instance of InterSystems IRIS. Port and username should be OK but verify these are correct as well.

Use SQL for CRUD operations: Create, Read, Update, Delete

  1. Run multimodelQS.py which executes the populateAirports() and getAirports() methods.
  2. Inspect the output and code. The first method — populateAirports() — populates five objects and saves them to the database, while the second method — getAirports() — runs an SQL query and returns all airports, printing them to the screen.
Not only are you able to create and read data as shown in the sample code, with InterSystems IRIS you can also use SQL to update, delete, and perform many other actions to interact with data.

Create a custom data structure, optimizing development time and performance

In the case where you need to answer a question you did not expect when you built the database, refactoring a relational-only database could be expensive and complicated. With InterSystems IRIS, you may choose to natively store data in a custom data structure, allowing you to modify the structure to fit your specific data and easily handle new data that was not part of your initial schema or class design.
  1. Two functions — StoreAirfare() and CheckAirfare() — have been created to store route information to InterSystems IRIS and print if a particular route exists. Uncomment the lines that call StoreAirfare() and CheckAirfare() to see how they work:
    // StoreAirfare(irisNative); 
    // CheckAirfare(irisNative);
  2. To test this, run the code and enter in values to see if there are routes from BOS to AUS. You should find there are routes available. You can run it again and try BOS to LAX, which should return no available routes.

Try it: InterSystems ObjectScript

With InterSystems ObjectScript, you can interact with InterSystems IRIS relationally, using objects, or natively. For this exercise, you should use Atelier. In the steps below, you will create a set of airport data as objects, retrieve that data via SQL, and then natively access custom data structures to store route information. Please note that ObjectScript is not currently supported in the IDE that is provided in the Learning Labs and Evaluation instances. You must use Atelier.

Setup

  1. Get the sample ObjectScript code:
    1. Clone this repo: https://github.com/intersystems/quickstarts-multimodel-objectscript
    2. Compile the sample code in Atelier. You should now have two new classes: Demo.Airport and Demo.Location.

Use objects and SQL side-by-side

  1. Open a terminal and run:
    do ##class(Demo.Airport).PopulateAirports()
    do ##class(Demo.Airport).DisplayAirports()
  2. Inspect the output and code. The first method — populateAirports() — populates five objects and saves them to the database, while the second method — getAirports() — runs an SQL query and returns all airports, printing them to the screen.
Tip
If you inspect the code, you will notice that the query uses a special shorthand notation (->, known as an implicit join) to retrieve data from a related table without requiring you to think about how to join tables. Using InterSystems IRIS, you can interact with data using either objects or SQL based on the task, optimizing both developer time and application performance.

Create a custom data structure, optimizing development time and performance

In the case where you need to answer a question you did not expect when you built the database, refactoring a relational-only database could be expensive and complicated. With InterSystems IRIS, you may choose to natively store data in a custom data structure, allowing you to modify the structure to fit your specific data and easily handle new data that was not part of your initial schema or class design.
  1. Another method — StoreAirfare() — has been created to store route information to InterSystems IRIS and print if a particular route exists. Run this method to see this work:
    do ##class(Demo.Airport).StoreAirfare()
  2. To test this, run the code and enter in values to see if there are routes from BOS to AUS. You should find there are routes available. You can run it again and try BOS to LAX, which should return no available routes.