Article
· Sep 10, 2016 3m read

NewBie's Corner Session 26 Globals and Arrays Part 2

NewBie's Corner Session 26 Globals and Arrays Part 2

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Globals, Arrays, and Variables Part 2

A thorough understanding of Globals, Arrays, and Variables is foundational for every Caché developer.

Uniqueness of the Caché Global Structure or database

The Caché Database Structure is unique among databases; it was designed and created in the 1960s to be used primarily with HealthCare applications. It has thrived in the Healthcare Industry as well as Financial Information systems and others. It was designed for use in multi-user database-driven applications. It predates "C" and most other current popular languages, and has a very different syntax and terminology.

The Caché Global Structure provides the programmer with a culture of unique freedom in accessing and modifying data without inefficient built-in safeguards. Rather, it relies on the programmer having a disciplined approach to data manipulation.

The Caché Global Structure is based on a B-Tree concept (see below), which permits data to exist in a permanent sorted state, and allows for efficient searches, access, insertions, and deletions. In other words, the data is always sorted, (or indexed) which greatly improves the efficiency of data access.

The Caché Database Structure employs Sparse Arrays. A Sparse Array is an Array without data being populated in all entries. There is no wasted memory or hard disk space with Caché Sparse Arrays. Using Sparse Arrays, data can be inserted into the database quickly and efficiently.

Data stored in Globals is available to every Caché process running on the system. As soon as a Global or Global node is created, it is instantly available to all other processes on the system. This provides a freedom of data access without the excessive overhead of data and record locking seen in other databases. At first glance this may seem chaotic, but handled correctly by the programmer, it works and provides tremendous scalability of data, from a few bytes to terabytes with speeds that far exceed other technologies.

Uniqueness of Caché Variables

Variables created by one routine are accessible by all routines in a session. This means that if RoutineA creates a variable, RoutineB can access, change or even delete that variable. This allows the programmer a certain freedom in his code. This strategy can be successful as long as the programmer is disciplined in his code writing and uses appropriate Scoping methods like the New command. A Scope is the context within a computer program in which a variable name can be used. Outside of the scope of a variable, the variable's value is not accessible.

B-Tree

In computer science, a B-tree is a self-balancing tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree is a generalization of a binary search tree in that a node can have more than two children (Comer 1979, p. 123). Unlike self-balancing binary search trees, the B-tree is optimized for systems that read and write large blocks of data. B-trees are a good example of a data structure for external memory. It is commonly used in databases and filesystems.

--Mike Kadow

PaulMikeKadow@gmail.com

If you have a comment, please respond through the InterSystems Developer Community, don't send me private email, unless of course you wish to address me only.

See "Newbie's Corner Index" for an index of all NewBies' Posts

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