Home  /  Application Development: Core Topics  /  Orientation Guide for Server-Side Programming  /  Namespaces and Databases

Orientation Guide for Server-Side Programming
Namespaces and Databases
[Back]  [Next] 
InterSystems: The power behind what matters   

This chapter describes how InterSystems IRIS™ organizes data and code. It discusses the following:
Introduction to Namespaces and Databases
In InterSystems IRIS, any code runs in a namespace, which is a logical entity. A namespace provides access to data and to code, which is stored (typically) in multiple databases. A database is a file — an IRIS.DAT file. InterSystems IRIS provides a set of namespaces and databases for your use, and you can define additional ones.
In a namespace, the following options are available:
Mappings provide a convenient and powerful way to share data and code. Any given database can be used by multiple namespaces. For example, there are several system databases that all customer namespaces can access, as discussed later in this chapter.
You can change the configuration of a namespace after defining it, and InterSystems IRIS provides tools for moving code and data from one database to another. Thus you can reorganize your code and data during development, if you discover the need to do so. This makes it possible to reconfigure InterSystems IRIS applications (such as for scaling) with little effort.
Locks, Globals, and Namespaces
Because a global can be accessed from multiple namespaces, InterSystems IRIS provides automatic cross-namespace support for its locking mechanism. A lock on a given global applies automatically to all namespaces that use the database that stores the global.
For an introduction to locking, see Locking and Concurrency Control,” earlier in this book.
Database Basics
An InterSystems IRIS database is an IRIS.DAT file. You create a database via the Management Portal. Or if you have an existing InterSystems IRIS database, you can configure InterSystems IRIS to become aware of it.
Database Configuration
For any database, InterSystems IRIS requires the following configuration details:
Additional options include the following:
In most cases, you can create, delete, or modify database attributes while the system is running.
Database Features
With each database, InterSystems IRIS provides physical integrity guarantees for both the actual data and the metadata that organizes it. This integrity is guaranteed even if an error occurs during writes to the database.
The databases are automatically extended as needed, without manual intervention. If you expect a particular database to grow and you can determine how large it will become, you can “pre-expand” it by setting its initial size to be near the expected eventual size. If you do so, the performance is better.
InterSystems IRIS provides a number of strategies that allow high availability and recoverability. These include:
InterSystems IRIS has a technology for distributing data and application logic and processing among multiple systems. It is called the Enterprise Cache Protocol (ECP). On a multiserver system, a network of InterSystems IRIS database servers can be configured as a common resource, sharing data storage and application processing, with the data distributed seamlessly among them. This provides increased scalability as well as automatic failover and recovery.
Database Portability
InterSystems IRIS databases are portable across platforms and across versions, with the following caveat:
System-Supplied Databases
InterSystems IRIS provides the following databases:
For additional detail on IRISSYS, see the chapter Assets and Resources in the Security Administration Guide.
%SYS Namespace
The %SYS namespace provides access to code that should not be available in all namespaces — code that manipulates security elements, the server configuration, and so on.
For this namespace, the default routine database and default global database is IRISSYS. If you follow certain naming conventions, you can create your own code and globals in this namespace and store it in that database. See the next section.
IRISSYS Database and Custom Items
You can create items in the IRISSYS database. When you install an InterSystems IRIS upgrade, this database is upgraded. During this upgrade, some items are deleted unless they follow the naming conventions for custom items.
To add code or data to this database so that your items are not overwritten, do one of the following:
MAC code and include files are not affected by upgrade.
What Is Accessible in Your Namespaces
When you create a namespace, the system automatically defines mappings for that namespace. As a result, in that namespace, you can use the following items (provided you are logged in as a user with suitable permissions for these items):
Via extended global references, your code can access globals that are defined in other namespaces. For information, see Global Structure in Using Globals.
The InterSystems security model controls which data and which code any user can access; see the chapter InterSystems IRIS Security for an introduction.
System Globals in Your Namespaces
Your namespaces contain additional system globals, which fall into two rough categories:
In most cases, you should not manually write to or delete any of these globals. See Global Naming Conventions,” in Using Globals.
Stream Directory
In any given namespace, when you create a file stream, InterSystems IRIS writes a file to a default directory and then later deletes it.
This is important because your users will need write access to this directory; if not, your code will not be able to create file streams.
The default directory is the stream subdirectory of the global database for this namespace.
For More Information
For more information on the topics covered in this chapter, see the following: