DEV Community

InterSystems Developer for InterSystems

Posted on • Originally published at community.intersystems.com

How to separate source code and data in different databases

Image description

 

📜 Santa Tecla, verse 8: "Hover your mouse over the screen, and the sea of data will open a path before you!!"

 

Hello community, first of all, apologies if anyone was offended by the blasphemy 😔

Have you ever thought it would be interesting to have the source code separated from the database data? Perhaps you'd like to be able to back up your code without copying gigabytes of client data.

Below, I'll explain the steps to separate your sea formed by the source code and data into two different databases within a namespace.

For this example, I'll start with a new namespace that I'll create for the demonstration.

 

First, we will create 2 new databases:

1. Access the portal and navigate to the section for Local Databases:

Image description

 

We will click on the "Create New Database" button:

Image description

 

We will give it a name and specify the folder where it will be stored (I've prefixed it with "Tutorial" because I plan to name the Namespace "Tutorial"):

Image description

 

Now it allows us to choose the size we want to allocate and whether we want to enable journaling for it:

Image description

 

We select "Create New Resource":

Image description

 

We assign the name of the new resource, provide a description, and if appropriate, mark the permissions for public access:

Image description

 

Next, we follow the same steps for the other database for the data:

Image description

We also select "Create New Resource":

Image description

 

Now we have our two databases created.

Image description

 

Now we will create the new Namespace and assign the 2 Databases we just created to it.

We access the Namespaces section:

Image description

 

 

We click on the "Create new Namespace" button.

Image description

 

We give it a name and choose the database for the data and for the source code, then we click the "Save" button.

Image description

 

And voilà, we now have our shiny new namespace created with 2 separate databases—one for data and another for source code.

Image description

This could also be very useful in situations like... Imagine you have a database with a massive amount of data that is shared by all members of the development team.

These team members might have laptops that they carry around, and you wouldn't want those laptops to have a local copy of the database data, either for security reasons or because it would require creating test data on all of them.

In that case, it could be a good idea to create the source code Namespace locally and the routines in a remote database. "What? How would you connect to a remote database?" Piece of cake!

 

Connecting to a remote database. **You need to configure the remote server as ECP (I'll explain it at the end of the tutorial).

We go to the section for remote servers to configure it (if it's not already configured).

Image description

 

We click on the "Data Servers" button:

Image description

 

And we add the new server.

Image description

 

We fill in the information:

Image description

 

 

By default, it will create it as disabled. Click the "Change State" button to activate it:

Image description

 

 

Now we go to the section for Remote Databases.

Image description

 

And we click on the "Create Remote Database" button:

Image description

We will select the server that hosts the remote database and choose it from the dropdown menu:

Image description

 

Next, we are going to create a new "Hybrid" Namespace with the source code information on the local machine and the data on a remote server.

We access the Namespaces section and click on the create Namespace button. This time, under the database section for globals, we will select the Remote Database option and choose the remote Database we have created:

Image description

 

And now we have our amazing Hybrid Namespace configured!

Image description

**Configuring server as ECP (to serve remote databases, requires a paid license):

Image description

 

We set the maximum number of data servers, SSL options, etc., and then click on the "Save" and "Activate" buttons:

Image description

 

Now, we could indeed have our data separated within the same server or even across different servers.

Here's a video on how to create databases and create/configure a Namespace:

 

 

I hope this tutorial makes the long journey through the desert 🌴🐪 to earn forgiveness from the CTO / CIO and reach the promised retirement more enjoyable.

See you in the next post! Let me know if you found this article interesting; all your comments or questions are always welcome. 🙌

Top comments (0)