LogoLogo
BlogDiscordGitHubDoltgres
  • Introduction
    • What is Doltgres?
    • Installation
    • Getting Started
  • Concepts
    • Git
      • Commits
      • Log
      • Diff
      • Branch
      • Merge
      • Conflicts
      • Remotes
      • Working Set
    • SQL
      • Databases
      • Schema
      • Tables
      • Primary Keys
      • Types
      • Indexes
      • Views
      • Constraints
      • Triggers
      • Functions
      • Procedures
      • Users/Grants
      • Transactions
      • System Variables
    • RDBMS
      • Server
      • Backups
      • Replication
  • Guides
    • Cheat Sheet
    • Replication from Postgres
  • Reference
    • Running the Server
      • Configuration
      • Access Management
      • Branch Permissions
      • Backups
      • Garbage Collection
      • Metrics
      • Replication
      • Troubleshooting
    • Version Control Features
      • Using Branches
      • Merges
      • Querying History
      • Using Remotes
      • Functions
      • System Tables
      • System Variables
    • SQL Language Support
      • Supported Functions and Operators
      • Supported Types
      • Supported SQL Commands
      • System Catalog Schema
    • Supported Clients
      • Programmatic
    • Benchmarks
      • Correctness
      • Latency
Powered by GitBook
On this page
  • What is a Schema?
  • How to use Schema
  • Difference between Postgres Schema and Doltgres Schema
  • Interaction with Doltgres Version Control
  1. Concepts
  2. SQL

Schema

PreviousDatabasesNextTables

Last updated 11 months ago

What is a Schema?

Schema defines the shape of the data in your database.

are the core unit of schema. Tables have columns and rows. Each column in a table has a . A table can have one or more , the combination of which identify the row and must be unique. Columns can also be assigned additional , including foreign key constraints which are references to other tables in the database.

Schema also includes . Views look like tables but the data in them is generated using SQL stored in the view definition. The data is stored in the tables the views reference not the view itself.

are a part of schema. An index allows read query performance to be improved at the expense of write performance and increased storage.

Finally, schema includes and . Triggers and procedures are code stored in your database that executes on specific conditions or when a user asks, respectively.

How to use Schema

Schema is the core of database design. You use schema to explain to database users the shape of the data in the database. What values are allowed in this column? What data is allowed to be duplicated in multiple rows? Can a value exist in this table without existing in this other table as well?

Schema design also effects the performance of queries against the database. Defining primary keys and indexes correctly can make your database perform for large databases or complex queries.

Changing schema can be a costly operation. For instance, adding an index to a column on a running database requires scanning the entire table and writing a new index artifact, usually while also restricting writes to that table.

Difference between Postgres Schema and Doltgres Schema

Doltgres supports , with more support being built out now.

Interaction with Doltgres Version Control

Doltgres versions your schema and data. So, if you want to see the difference between the schema of two different versions, Doltgres provides this using diff functionality. See individual SQLconcepts for how Doltgres handles each individual schema element with regards to versioning.

Tables
type
primary keys
constraints
views
Secondary Indexes
triggers
procedures
most Postgres schema elements at least partially