Record Class DatabaseRelationSymbol

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.relation.DatabaseRelationSymbol
Record Components:
namespace - the namespace this symbol belongs to; must not be blank
declaredName - the name as written by the user; must not be blank
provenance - built-in or user-defined; must not be null
shadowPolicy - replacement policy for this symbol; must not be null
schema - the structural description of the relation; must not be null
All Implemented Interfaces:
RelationSymbol, Symbol

public record DatabaseRelationSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, Schema schema) extends Record implements RelationSymbol
A relation symbol backed by an external data store — typically a database table or view.

Only the Schema is stored here; the actual row data lives in the external system. This symbol tells semantic analysis what columns the relation has and what their types are, allowing queries over it to be validated without executing them.

The convenience factory of(String, Schema) creates a user-owned symbol in the "default" namespace with ShadowPolicy.PERMITTED:


 DatabaseRelationSymbol users = DatabaseRelationSymbol.of("Users",
     new Schema(List.of(
         new ColumnDefinition("id",   ScalarType.NUMBER),
         new ColumnDefinition("name", ScalarType.STRING)
     )));
 
  • Constructor Details

    • DatabaseRelationSymbol

      public DatabaseRelationSymbol(String namespace, String declaredName, Provenance provenance, ShadowPolicy shadowPolicy, Schema schema)
      Creates an instance of a DatabaseRelationSymbol record class.
      Parameters:
      namespace - the value for the namespace record component
      declaredName - the value for the declaredName record component
      provenance - the value for the provenance record component
      shadowPolicy - the value for the shadowPolicy record component
      schema - the value for the schema record component
  • Method Details

    • of

      public static DatabaseRelationSymbol of(String name, Schema schema)
      Creates a user-defined database relation in the "default" namespace with ShadowPolicy.PERMITTED.
      Parameters:
      name - the relation name; must not be blank
      schema - the relation's column schema; must not be null
      Returns:
      a new DatabaseRelationSymbol
    • builtin

      public static DatabaseRelationSymbol builtin(String name, Schema schema)
      Creates a built-in database relation in the "builtin" namespace with ShadowPolicy.FORBIDDEN.
      Parameters:
      name - the relation name; must not be blank
      schema - the relation's column schema; must not be null
      Returns:
      a new DatabaseRelationSymbol
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • namespace

      public String namespace()
      Returns the value of the namespace record component.
      Specified by:
      namespace in interface Symbol
      Returns:
      the value of the namespace record component
    • declaredName

      public String declaredName()
      Returns the value of the declaredName record component.
      Specified by:
      declaredName in interface Symbol
      Returns:
      the value of the declaredName record component
    • provenance

      public Provenance provenance()
      Returns the value of the provenance record component.
      Specified by:
      provenance in interface Symbol
      Returns:
      the value of the provenance record component
    • shadowPolicy

      public ShadowPolicy shadowPolicy()
      Returns the value of the shadowPolicy record component.
      Specified by:
      shadowPolicy in interface Symbol
      Returns:
      the value of the shadowPolicy record component
    • schema

      public Schema schema()
      Returns the value of the schema record component.
      Specified by:
      schema in interface RelationSymbol
      Returns:
      the value of the schema record component