In Polypheny, namespaces play a significant role in the organization and structuring of data, serving as the backbone for defining logical schemas. Understanding namespaces is crucial for the effective use of Polypheny’s PolyDBMS. This document provides an in-depth overview of namespaces in Polypheny, explaining what they are, how they’re used, and the benefits they offer.
What are Namespaces?
Namespaces in Polypheny are essentially logical containers that segregate different data models within the logical schema of the PolyDBMS. Each namespace is identified by a unique name and corresponds to a specific data model.
When you define a schema, you’re defining it within a namespace, and this namespace determines the rules and semantics for that schema based on the corresponding data model. For instance, a namespace associated with a relational model will mandate strict schema rules, while a namespace related to a document model will allow a schema-less structure.
Namespaces in Polypheny provides several key benefits:
-
Organization: Namespaces allow for logical segmentation of your database according to different data models. This makes it easier to manage and structure your data based on its inherent characteristics.
-
Flexibility: With each namespace corresponding to a different data model, you have the flexibility to choose the most appropriate data model for each portion of your data.
-
Interoperability: Despite the separation of data models using namespaces, Polypheny allows cross-namespace queries. This means you can run a single query that joins data from entities residing in different namespaces.
-
Simplicity: Namespaces simplify the user’s interaction with the data by abstracting away the complexity of managing different data models. A user interacts with the data in a way consistent with the logical schema, oblivious of the complexities underneath.
Defining Namespaces
When setting up a logical schema in Polypheny, you start by defining the namespaces. Each namespace is allocated a unique name and is associated with a specific data model. This effectively segments your database into multiple logical spaces, each with its unique characteristics based on the underlying data model.
Namespaces can be created within the user interface or using the SQL CREATE NAMESPACE syntax.
Creating Entities within Namespaces
Once a namespace is defined, entities (like tables, documents, or nodes, depending on the data model) can be created within the namespace. These entities adhere to the rules of the corresponding data model. For instance, if you’re working within a namespace associated with a relational model, you’d create tables with a fixed schema.
Entities can be created using any query language support DDL operations. Please note that DDL statements are always limited to namespace based on the same data model as the query langues. Thus, SQL only allows to create or alter tables in relational namespaces and cannot be used to create collections or graphs.
Referencing Namespaces in Queries
In Polypheny, namespaces also come into play when writing queries. When referencing an entity in a query, you must specify the namespace where that entity resides. This allows Polypheny to correctly interpret the query in the context of the corresponding data model.
Naming Rules
Every namespace must have a unique name. Namespace names are always treated case-insensitive and must only contain characters and numbers. Furthermore, namespace names must start with a letter. Please note that namespace names are automatically converted to lower-case.
Forbidden names:
- “database”
- “db”
- “graph”
- “namespace”
- “schema”