Article
· Jul 13 3m read

How to separate source code and data in different databases

   

 

📜 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:

 

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

 

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"):

 

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

 

We select "Create New Resource":

 

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

 

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

We also select "Create New Resource":

 

Now we have our two databases created.

 

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

We access the Namespaces section:

 

 

We click on the "Create new Namespace" button.

 

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

 

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

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).

 

We click on the "Data Servers" button:

 

And we add the new server.

 

We fill in the information:

 

 

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

 

 

Now we go to the section for Remote Databases.

 

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

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

 

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:

 

And now we have our amazing Hybrid Namespace configured!

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

 

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

 

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:

 

https://www.youtube.com/embed/uHT0d_qEPUc
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

 

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. 🙌

Discussion (0)1
Log in or sign up to continue