# Type Constraints in 65 lines of SQL

DevFeed: [Type Constraints in 65 lines of SQL](<https://devfeed.tech/articles/type-constraints-in-65-lines-of-sql-699.md>)

Original publisher: [Read original article](<https://supabase.com/blog/type-constraints-in-65-lines-of-sql>)

Author: Oliver Rice

Published: 2023-02-17T07:00:00Z

Content type: article

Language: en

Sources: [Supabase Blog](<https://devfeed.tech/sources/supabase-blog.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [data](<https://devfeed.tech/tags/data.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [sql](<https://devfeed.tech/tags/sql.md>), [validation](<https://devfeed.tech/tags/validation.md>)

## AI overview

This article explains how to create a validated Semantic Versioning data type in PostgreSQL using composite types, domains, SQL casting, and validation rules. It demonstrates how constraints can reject invalid states while preserving flexible querying and efficient storage.

## Source excerpt

Creating validated data types in Postgres