CINXE.COM

Custom data types: DOMAINS | Tutorials | Crunchy Data

<!DOCTYPE html><html lang="en" class="h-full"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta property="og:url" content="https://www.crunchydata.com/developers/playground/custom-data-types-domains"/><meta property="og:site_name" content="Crunchy Data"/><meta name="twitter:site" content="@crunchydata"/><meta name="twitter:creator" content="@crunchydata"/><title>Custom data types: DOMAINS | Tutorials | Crunchy Data</title><meta name="description" content="Learn about user-defined datatypes, domain types, and how to create constraints that validate values."/><meta property="og:title" content="Custom data types: DOMAINS | Tutorials | Crunchy Data"/><meta property="og:description" content="Learn about user-defined datatypes, domain types, and how to create constraints that validate values."/><meta property="og:type" content="website"/><meta property="og:image:type" content="image/png"/><meta property="og:image" content="https://www.crunchydata.com/build/_assets/card-XNLWLAYT.png"/><meta property="og:image:secure_url" content="https://www.crunchydata.com/build/_assets/card-XNLWLAYT.png"/><meta property="og:image:height" content="1334"/><meta property="og:image:width" content="751"/><meta property="og:image:alt" content="Postgres terminal in the browser."/><meta name="twitter:card" content="summary_large_image"/><link rel="canonical" href="https://www.crunchydata.com/developers/playground/custom-data-types-domains"/><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin=""/><link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&amp;display=swap" rel="preload" as="style"/><link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&amp;display=swap" rel="stylesheet"/><link rel="stylesheet" href="/build/_assets/app-2WZ6DH7F.css"/><link rel="stylesheet" href="/build/_assets/syntax-highlighting-SVOKP4VM.css"/><link rel="stylesheet" href="/build/_assets/xterm-5RZFAHCC.css"/></head><body class="h-full text-slate-900"><svg aria-hidden="true" width="0" height="0"><filter id="noise"><feTurbulence baseFrequency="0.60" result="colorNoise"></feTurbulence><feColorMatrix in="colorNoise" type="matrix" values=".33 .33 .33 0 0 .33 .33 .33 0 0 .33 .33 .33 0 0 0 0 0 0.5 0"></feColorMatrix><feComposite operator="in" in2="SourceGraphic" result="monoNoise"></feComposite><feBlend in="SourceGraphic" in2="monoNoise" mode="multiply"></feBlend></filter></svg><svg aria-hidden="true" width="0" height="0"><filter id="noise-spicy"><feTurbulence baseFrequency="0.60" result="colorNoise"></feTurbulence><feColorMatrix in="colorNoise" type="matrix" values=".33 .33 .33 0 0 .33 .33 .33 0 0 .33 .33 .33 0 0 0 0 0 1.0 0"></feColorMatrix><feComposite operator="in" in2="SourceGraphic" result="monoNoise"></feComposite><feBlend in="SourceGraphic" in2="monoNoise" mode="multiply"></feBlend></filter></svg><svg aria-hidden="true" width="0" height="0"><filter id="noise-mild"><feTurbulence baseFrequency="0.60" result="colorNoise"></feTurbulence><feColorMatrix in="colorNoise" type="matrix" values=".33 .33 .33 0 0 .33 .33 .33 0 0 .33 .33 .33 0 0 0 0 0 0.3 0"></feColorMatrix><feComposite operator="in" in2="SourceGraphic" result="monoNoise"></feComposite><feBlend in="SourceGraphic" in2="monoNoise" mode="multiply"></feBlend></filter></svg><svg aria-hidden="true" width="0" height="0"><defs><pattern id="dot-pattern-x" height="1" width="3" patternUnits="userSpaceOnUse"><rect width="1" height="1" class="fill-blue-950/30"></rect></pattern><pattern id="dot-pattern-y" width="1" height="3" patternUnits="userSpaceOnUse"><rect width="1" height="1" class="fill-blue-950/30"></rect></pattern></defs></svg><div class="h-full flex flex-col"><div class="motion-safe:invisible motion-safe:-translate-y-full bg-seafoam text-teal-950 font-medium text-[15px] px-4 py-2.5 flex items-center lg:justify-center gap-4"><div class="lg:ml-auto"><p><strong class="font-semibold">Introducing Crunchy Data Warehouse</strong>: A next-generation Postgres-native data warehouse. <a class="group/link inline-flex items-center font-semibold text-blue-700 hover:text-blue-900 transition-colors" href="/products/warehouse"><span class="sr-only">Crunchy Data Warehouse </span>Learn more<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="ml-0.5 group-hover/link:translate-x-1 transition-transform size-5 opacity-40 mt-0.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 7l5 5m0 0l-5 5m5-5H6"></path></svg></a></p></div><form method="post" action="/" class="flex items-center ml-auto"><button type="submit" name="closeGlobalBanner" value="on" class="p-1 hover:bg-teal-900/15 transition-colors rounded disabled:opacity-50"><span class="sr-only">Close</span><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg></button></form></div><nav class="dark bg-gray-900 border-b border-gray-700 text-white invert-color relative z-40" data-headlessui-state=""><div class="mx-auto flex h-16 max-w-7xl items-center justify-between gap-6 px-4 sm:px-6 lg:px-8"><a class="-mx-2 flex items-center p-2" aria-label="Home" href="/"><svg id="round-light_svg__Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 213 207.3" style="enable-background:new 0 0 213 207.3" xml:space="preserve" class="hidden lg:block h-8 w-auto xl:hidden"><style>.round-light_svg__st1{fill:#060606}.round-light_svg__st2{fill:#fff}</style><path class="round-light_svg__st1" d="M109.4 207.3c-48.9-.4-91.7-31.9-105.1-77.3C-12.2 74.1 20.1 17.6 77 3.7 120-6.8 156.9 5 186.1 37.6c33.8 37.7 35.4 90.5 6.6 128.6-17.5 23.1-40.9 36.4-69.6 40.1-3.5.5-7.1.7-10.6 1h-3.1zM101.5 5.2c-2.9 0-5.9-.1-8.8 0-1 0-2.8.3-2.1 1.8 1.3 2.5 2.7 5.1 4.8 6.9 1.6 1.3 4.1 0 6.1-.6l14.4-1.6h20.4c-6.7-3.5-13.9-4.7-21.1-5.2-4.6.4-9-1.9-13.7-1.3zM53.2 18.8c-11.6 5.9-20.8 14.8-28.5 25C11.6 61 5.5 80.9 5.9 102.5c.4 20.9 6.8 39.9 19.5 56.7 3.4 4.5 6.9 9 11.5 12.6.8-1.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 2.2-5.2 4.1-8.1 5.6-5.5 2.6-7.6 7.3-7.8 12.7-.1 5.9-2.2 10.3-7.3 13.2-1.9 1-2.9 3.3-5.2 3.6-2.7 2.9-6.1 3.7-9.9 3.6-2.4-.1-4.8 0-7.2 0-4.9 0-8.1 2.2-9.7 6.7-1.2 3.3-2.9 6.1-5.8 8.3-1.7 1.2-2.9 3-3.5 5C15.2 90 12 99.8 11 110c-.5 5.3.8 9.7 6.1 12 .5.2.9.6 1.1 1.1 5.8 11 15.1 17.9 26.8 21.6 2.9.9 2.7 1.8 1.1 3.7l-3.9 4.8c-3.5 4.5-5.4 9.5-4.9 15.3.1 1 .3 2-.5 3.2-4.6-3.7-8.1-8.2-11.5-12.7-12.6-16.8-19-35.8-19.5-56.7-.3-21.5 5.8-41.3 18.9-58.5 7.7-10.2 16.9-19.1 28.5-25 10.1-6.5 21.1-10.1 33.4-12zM158.7 23c17.3 17.7 31.8 37.8 43.2 59.8 1.1-16.1-27.4-55.6-43.2-59.8zM101.5 5.2c-2.9 0-5.9-.1-8.8 0-1 0-2.8.3-2.1 1.8 1.3 2.5 2.7 5.1 4.8 6.9 1.6 1.3 4.1 0 6.1-.6l14.4-1.6h20.4c-6.7-3.5-13.9-4.7-21.1-5.2-4.6.4-9-1.9-13.7-1.3z" style="fill:#0f64f8"></path><path class="round-light_svg__st1" d="M111.8 40.4c1.4.1 2.7.5 3.9 1.2 1.1.6 1.3 1.9.6 2.1-2.6.7-2.2 3.1-3 4.8-2.2 4.7-7.4 5.7-11.4 2.1-.6-.5-.9-1.7-2.1-.8-.7.5-1.7 1.2-2.4 0-.6-.9-.3-1.9.4-2.8 3-3.7 9.3-6.7 14-6.6zM59.3 91.9c-4.8-1.4-10.5-.9-14.2-5.4-.5-.6-1.3-1.2-1.4-1.9-.2-1.1-1.7-2.5-.3-3.4 1.5-.9 2.1.9 2.8 1.7 3.3 4.2 7.8 3.5 12.2 3 1.8-.2 3.5-1.1 5.1-1.9 1.2-.6 2.1-.7 3 .4.9 1.1.9 2.3.1 3.4-1.6 2.7-4.2 3.6-7.3 4.1z"></path><path class="round-light_svg__st1" d="M53.9 72.2c2.5 0 4.4 2.4 4.5 5.5 0 2.5-2.1 5.3-4 5.2-1.8-.1-5.5-5.2-5.3-7.4.3-2.9 2.6-3 4.8-3.3z"></path></svg><svg id="logo-light_svg__Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 995.5 227.7" style="enable-background:new 0 0 995.5 227.7" xml:space="preserve" class="lg:hidden h-10 w-auto xl:block"><style>.logo-light_svg__st0{fill:#0f64f8}.logo-light_svg__st1{fill:#060606}.logo-light_svg__st2{fill:#fff}</style><path class="logo-light_svg__st0" d="M319.2 110.9h-16.5c-1.5-4.6-5.6-7.5-11.5-7.5-9 0-14.4 7-14.4 17.4 0 9.7 5.4 17.5 14.9 17.5 5.3.2 10.1-3.1 11.7-8.1h16.9c-3.4 12.1-12.3 22.3-28.9 22.3-17.5 0-31.6-12.5-31.6-31.8 0-17.3 12-31.3 31.5-31.3 16.9-.1 26 11.6 27.9 21.5zM370.9 105.6c-2.6-.5-5.3-.7-7.9-.7-9.9 0-14.8 6.2-14.8 16.8v28.8h-16.7V91.3h16.3v9.1h.4c3.2-5.8 9.4-10.9 17.3-10.9 1.8-.1 3.6.1 5.4.5v15.6zM435 150.4h-16.5V143h-.4c-4.8 7-10.9 9.4-17.3 9.4-9.6 0-21.5-5.9-21.5-26v-35H396v32.9c0 8.6 4.1 13.3 10.5 13.3 7.3 0 11.8-5.1 11.8-14.9V91.3H435v59.1zM450.2 91.3h16.4v7.4h.5c4.1-6.5 10.7-9.3 17.5-9.3 13.3 0 22.6 8.9 22.6 27v33.9h-16.6v-32.8c0-8.9-4.2-13.4-11.1-13.4-7.3 0-12.6 5.2-12.6 15.1v31.3h-16.7V91.3zM577.4 110.9h-16.6c-1.5-4.6-5.6-7.5-11.5-7.5-9 0-14.4 7-14.4 17.4 0 9.7 5.4 17.5 14.9 17.5 5.3.2 10.1-3.1 11.7-8.1h16.9c-3.4 12.1-12.3 22.3-28.9 22.3-17.5 0-31.6-12.5-31.6-31.8 0-17.3 12-31.3 31.5-31.3 17-.1 26.1 11.6 28 21.5zM589.7 61.5h16.7v37.2h.5c4.1-6.5 10.7-9.3 17.4-9.3 13.2 0 22.5 8.8 22.5 27v33.9H630v-33c0-8.8-4.2-13.3-11.1-13.3-7.3 0-12.6 5.1-12.6 15.1v31.3h-16.6V61.5zM678.4 179.4h-15.8l10.9-29.5L652 91.2h17.3l8.5 25.7c1.6 4.8 2.9 9.6 4 14.5h.5c1-4.9 2.3-9.8 3.8-14.5l8.3-25.7h16.4l-32.4 88.2z"></path><path class="logo-light_svg__st2" d="M789.3 150.4h-9.7v-7.9h-.2c-5.5 6.5-13.6 10.2-22.1 10.1-16 0-29.9-12.5-29.9-31.7 0-17.9 12.7-31.5 29.9-31.5 11.2 0 17 4.5 22.1 10.4h.2V61.5h9.7v88.9zm-30.4-6.6c11.5 0 21.5-9.3 21.5-22.7 0-14.1-9.4-23.3-21.2-23.3-14.4 0-21.7 11.5-21.7 23s7.2 23 21.4 23zM864.2 150.4h-9.7v-7.9h-.2c-5.3 6.4-13.3 10.1-21.6 10.1-16 0-30.4-12.5-30.4-31.7 0-18.3 13.3-31.5 31-31.5 10.7 0 17 5.7 21.1 10.5h.1v-8.5h9.7v59zm-30.3-6.6c11.1 0 21.4-9.4 21.4-22.7 0-14.1-9.5-23.3-21.1-23.3-14.8 0-21.8 11.6-21.8 23s7 23 21.5 23zM874.8 91.3h7.8V72.4h9.7v18.9h15.8v8.1h-15.8v31.3c0 9.6 3 12.2 9.3 12.2 2.4 0 4.8-.3 7.2-1v8c-3 .9-6 1.3-9.1 1.2-14.3 0-17-9.6-17-20.9V99.4h-7.8l-.1-8.1zM977.3 150.4h-9.7v-7.9h-.3c-5.3 6.4-13.3 10.1-21.6 10.1-16 0-30.4-12.5-30.4-31.7 0-18.3 13.3-31.5 31-31.5 10.7 0 17 5.7 21.1 10.5h.1v-8.5h9.8v59zm-30.2-6.6c11.2 0 21.4-9.4 21.4-22.7 0-14.1-9.5-23.3-21.1-23.3-14.8 0-21.8 11.6-21.8 23s6.9 23 21.5 23z"></path><path class="logo-light_svg__st1" d="M129.8 218.4c-48.8-.3-91.7-31.9-105.1-77.2C8.3 85.3 40.6 28.8 97.5 14.9c42.9-10.5 79.9 1.3 109.1 33.8 33.8 37.7 35.4 90.5 6.6 128.6-17.5 23.1-40.9 36.4-69.6 40.1-3.5.5-7.1.7-10.6 1-1.1.1-2.1 0-3.2 0zm-7.8-202c-2.9 0-5.9-.1-8.8 0-1 0-2.8.3-2.1 1.8 1.3 2.5 2.7 5.1 4.8 6.9 1.6 1.3 4.1 0 6.1-.6l14.4-1.6h20.4c-6.7-3.5-13.9-4.7-21.1-5.2-4.6.3-9-2-13.7-1.3zM73.7 29.9c-11.6 5.9-20.8 14.8-28.5 25C32.2 72.1 26 92 26.4 113.6c.4 20.9 6.8 39.9 19.5 56.7 3.4 4.5 6.9 9 11.5 12.6.8-1.2.5-2.3.5-3.2-.5-5.8 1.5-10.8 4.9-15.3 1.3-1.6 2.5-3.2 3.9-4.8 1.6-1.9 1.8-2.8-1.1-3.7-11.6-3.7-20.9-10.6-26.8-21.6-.2-.5-.6-.9-1.1-1.1-5.3-2.3-6.6-6.7-6.1-12 1-10.3 4.1-20 6.8-29.9.6-2 1.8-3.8 3.5-5 2.9-2.1 4.6-4.9 5.8-8.3 1.6-4.6 4.8-6.7 9.7-6.7 2.4 0 4.8-.1 7.2 0 3.8.1 7.2-.6 9.9-3.6 2.4-.3 3.4-2.5 5.2-3.6 5.1-2.9 7.2-7.3 7.3-13.2.1-5.5 2.3-10.1 7.8-12.7 3-1.5 5.7-3.4 8.2-5.6 1.8-1.6 2.9-3.4 2.6-6-.5-3 .1-6.1 1.7-8.6-12.6 1.8-23.6 5.5-33.6 11.9zm44 63.9c5.7.1 9.9 2.6 13.7 5.9 7 6 8.8 22.6-1.5 28.2-9.2 5-18.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 1.3 1.4 1.9 3.6 4.5 9.3 4 14.1 5.3zm-5.4-19.7c-2.2.3-4.5.4-4.8 3.3-.2 2.2 3.5 7.3 5.3 7.4 1.9.1 4.1-2.6 4-5.2-.1-3.1-2-5.4-4.5-5.5z"></path><path class="logo-light_svg__st2" d="M92.6 153.1c3.7.3 7.3.6 11 .8 1.6.1 2 .6 1.3 2.1-3.4 7.3-6.8 14.5-10.1 21.8-.6 1.3-1.3 1.8-2.9 1.2-3.1-1.1-6.3-.1-9.5.3-.9.2-1.7.9-1.8 1.9-.2 1 .6 1.7 1.5 2.1.8.5 1.9.8 2.7 1.4 3.7 2.4 4.7 5.3 3.3 9.4-3 8.8-3 8.8-11.1 4l-3.2-1.9c-10.1-6-11.7-9.2-9.5-20.6 1.4-7.3 5.3-13.4 10.2-18.7 4-4.4 9.5-4 14.8-3.9 1 0 2.2.1 3.3.1z"></path><path class="logo-light_svg__st0" d="M107.1 17.9c-1.6 2.6-2.2 5.6-1.7 8.6.3 2.6-.7 4.4-2.6 6-2.4 2.2-5.2 4.1-8.1 5.6-5.5 2.6-7.6 7.3-7.8 12.7-.1 5.9-2.2 10.3-7.3 13.2-1.9 1-2.9 3.3-5.2 3.6-2.7 2.9-6.1 3.7-9.9 3.6-2.4-.1-4.8 0-7.2 0-4.9 0-8.1 2.2-9.7 6.7-1.2 3.3-2.9 6.1-5.8 8.3-1.7 1.2-2.9 3-3.5 5-2.6 9.9-5.8 19.7-6.8 29.9-.5 5.3.8 9.7 6.1 12 .5.2.9.6 1.1 1.1 5.8 11 15.1 17.9 26.8 21.6 2.9.9 2.7 1.8 1.1 3.7l-3.9 4.8c-3.5 4.5-5.4 9.5-4.9 15.3.1 1 .3 2-.5 3.2-4.6-3.7-8.1-8.2-11.5-12.7-12.6-16.8-19-35.8-19.5-56.7-.4-21.4 5.8-41.3 18.9-58.5 7.7-10.2 16.9-19.1 28.5-25 10-6.4 21-10.1 33.4-12zm72.1 16.2c17.3 17.7 31.8 37.8 43.2 59.8 1.1-16-27.4-55.5-43.2-59.8zM122 16.4c-2.9 0-5.9-.1-8.8 0-1 0-2.8.3-2.1 1.8 1.3 2.5 2.7 5.1 4.8 6.9 1.6 1.3 4.1 0 6.1-.6l14.4-1.6h20.4c-6.7-3.5-13.9-4.7-21.1-5.2-4.6.3-9-2-13.7-1.3z"></path><path class="logo-light_svg__st1" d="M132.3 51.5c1.4.1 2.7.5 3.9 1.2 1.1.6 1.3 1.9.6 2.1-2.6.7-2.2 3.1-3 4.8-2.2 4.7-7.4 5.7-11.4 2.1-.6-.5-.9-1.7-2.1-.8-.7.5-1.7 1.2-2.4 0-.6-.9-.3-1.9.4-2.8 3-3.6 9.2-6.6 14-6.6zM79.8 103c-4.8-1.4-10.5-.9-14.2-5.4-.5-.6-1.3-1.2-1.4-1.9-.2-1.1-1.7-2.5-.3-3.4 1.5-.9 2.1.9 2.8 1.7 3.3 4.2 7.8 3.5 12.2 3 1.8-.2 3.5-1.1 5.1-1.9 1.2-.6 2.1-.7 3 .4.9 1.1.9 2.3.1 3.4-1.6 2.7-4.3 3.6-7.3 4.1z"></path><path class="logo-light_svg__st1" d="M74.4 83.3c2.5 0 4.4 2.4 4.5 5.5 0 2.5-2.1 5.3-4 5.2-1.8-.1-5.5-5.2-5.3-7.4.3-2.9 2.6-3 4.8-3.3z"></path></svg></a><div class="hidden flex-grow justify-between lg:flex"><div class="flex"><div class="flex items-center" data-headlessui-state=""><div class="group relative index-1"><button class="group/btn relative flex h-full font-display items-center gap-1 py-2 px-3 text-sm rounded-md transition-colors font-semibold text-slate-900 dark:text-white" type="button" aria-expanded="false" data-headlessui-state="">Products<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="size-5 -mr-1 relative top-px text-slate-400 dark:text-white/60"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button><div class="left-0 lg:[.index-1_&amp;]:left-[-57px] xl:[.index-1_&amp;]:left-[-195px] lg:[.index-4_&amp;]:left-[-367px] xl:[.index-4_&amp;]:left-[-505px] origin-top-left absolute top-full mt-6 z-10 w-max lg:max-w-[calc(100vw-60px)] xl:max-w-[1216px] transform overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-lg ring-1 ring-black/5 dark:ring-gray-700" hidden="" style="display:none" id="headlessui-popover-panel-:Rib599p:" tabindex="-1" data-headlessui-state=""><div class="flex"></div></div></div></div><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><div class="flex items-center" data-headlessui-state=""><div class="group relative index-2"><button class="group/btn relative flex h-full font-display items-center gap-1 py-2 px-3 text-sm rounded-md transition-colors font-semibold text-slate-900 dark:text-white" type="button" aria-expanded="false" data-headlessui-state="">Cloud<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="size-5 -mr-1 relative top-px text-slate-400 dark:text-white/60"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button><div class="left-0 lg:[.index-1_&amp;]:left-[-57px] xl:[.index-1_&amp;]:left-[-195px] lg:[.index-4_&amp;]:left-[-367px] xl:[.index-4_&amp;]:left-[-505px] origin-top-left absolute top-full mt-6 z-10 w-max lg:max-w-[calc(100vw-60px)] xl:max-w-[1216px] transform overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-lg ring-1 ring-black/5 dark:ring-gray-700" hidden="" style="display:none" id="headlessui-popover-panel-:Rij599p:" tabindex="-1" data-headlessui-state=""><div class="flex"></div></div></div></div><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><div class="flex items-center" data-headlessui-state=""><div class="group relative index-3"><button class="group/btn relative flex h-full font-display items-center gap-1 py-2 px-3 text-sm rounded-md transition-colors font-semibold text-slate-900 dark:text-white" type="button" aria-expanded="false" data-headlessui-state="">Solutions<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="size-5 -mr-1 relative top-px text-slate-400 dark:text-white/60"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button><div class="left-0 lg:[.index-1_&amp;]:left-[-57px] xl:[.index-1_&amp;]:left-[-195px] lg:[.index-4_&amp;]:left-[-367px] xl:[.index-4_&amp;]:left-[-505px] origin-top-left absolute top-full mt-6 z-10 w-max lg:max-w-[calc(100vw-60px)] xl:max-w-[1216px] transform overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-lg ring-1 ring-black/5 dark:ring-gray-700" hidden="" style="display:none" id="headlessui-popover-panel-:Rir599p:" tabindex="-1" data-headlessui-state=""><div class="flex"></div></div></div></div><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><div class="flex items-center" data-headlessui-state=""><div class="group relative index-4"><button class="group/btn relative flex h-full font-display items-center gap-1 py-2 px-3 text-sm rounded-md transition-colors font-semibold text-slate-900 dark:text-white" type="button" aria-expanded="false" data-headlessui-state="">Developer?<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="size-5 -mr-1 relative top-px text-slate-400 dark:text-white/60"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button><div class="left-0 lg:[.index-1_&amp;]:left-[-57px] xl:[.index-1_&amp;]:left-[-195px] lg:[.index-4_&amp;]:left-[-367px] xl:[.index-4_&amp;]:left-[-505px] origin-top-left absolute top-full mt-6 z-10 w-max lg:max-w-[calc(100vw-60px)] xl:max-w-[1216px] transform overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-lg ring-1 ring-black/5 dark:ring-gray-700" hidden="" style="display:none" id="headlessui-popover-panel-:Rj3599p:" tabindex="-1" data-headlessui-state=""><div class="flex"></div></div></div></div><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><a class="flex h-full items-center py-2 px-3 transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white" href="/customers">Customers</a><a class="flex h-full items-center py-2 px-3 transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white" href="/pricing">Pricing</a></div><div class="flex"><a class="flex h-full items-center py-2 px-3 transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white" href="/blog">Blog</a><a class="flex h-full items-center py-2 px-3 transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white" href="/contact">Contact</a><div class="ml-3 flex items-center gap-3"><div class="flex items-center" data-headlessui-state=""><div class="group relative index-1"><button class="group/btn relative flex h-full font-display items-center gap-1 py-2 px-3 text-sm rounded-md transition-colors btn border border-blue-600/50 hover:border-blue-700 hover:bg-blue-700 text-blue-600 hover:text-white" type="button" aria-expanded="false" data-headlessui-state="">Login<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="size-5 -mr-1 relative top-px text-blue-600/50 group-hover/btn:text-white/60"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></button><div class="right-0 origin-top-right absolute top-full mt-6 z-10 w-max lg:max-w-[calc(100vw-60px)] xl:max-w-[1216px] transform overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-lg ring-1 ring-black/5 dark:ring-gray-700" hidden="" style="display:none" id="headlessui-popover-panel-:R15t599p:" tabindex="-1" data-headlessui-state=""><div class="flex"><div class="flex flex-col justify-between gap-4 lg:gap-x-7 lg:gap-y-0"><div class="flex-1 flex flex-col lg:max-w-80 gap-y-0.5"><div class="px-7 py-3.5"><div class="group/link flex flex-col space-y-1 relative -mx-3 px-3 lg: py-2 after:z-[-1] after:absolute after:inset-0 after:bg-gradient-to-br after:from-blue-50 after:to-blue-100 after:rounded-lg after:opacity-0 hover:after:opacity-100 after:scale-90 hover:after:scale-100 after:transition-all after:duration-150 dark:after:bg-blue-600 dark:after:from-blue-600 dark:after:to-blue-600"><a href="https://access.crunchydata.com" class="transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white">Access Portal<span class="absolute inset-0" aria-hidden="true"></span></a></div><div class="group/link flex flex-col space-y-1 relative -mx-3 px-3 lg: py-2 after:z-[-1] after:absolute after:inset-0 after:bg-gradient-to-br after:from-blue-50 after:to-blue-100 after:rounded-lg after:opacity-0 hover:after:opacity-100 after:scale-90 hover:after:scale-100 after:transition-all after:duration-150 dark:after:bg-blue-600 dark:after:from-blue-600 dark:after:to-blue-600"><a href="https://www.crunchybridge.com/login" class="transition ease-in-out duration-150 text-base lg:text-sm group-hover/link:text-blue-600 font-[550] dark:!text-white text-slate-900 dark:text-white">Crunchy Bridge<span class="absolute inset-0" aria-hidden="true"></span></a></div></div></div></div></div></div></div></div><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><a href="https://www.crunchybridge.com/register" class="btn py-2 px-3 text-sm font-semibold bg-blue-600 text-white hover:bg-blue-700 focus:bg-blue-700 active:bg-blue-700 group-focus-within:bg-blue-700">Register</a></div></div></div><div class="-my-2 -mr-2 lg:hidden"><button class="inline-flex items-center justify-center rounded-md bg-white dark:bg-gray-900 p-2 text-slate-400 dark:text-slate-100 hover:dark:bg-gray-800 hover:dark:text-white hover:bg-gray-100 hover:text-slate-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary" type="button" aria-expanded="false" data-headlessui-state=""><span class="sr-only">Open menu</span><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-6 w-6"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"></path></svg></button></div></div></nav><div style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0;display:none"></div><div class="flex-grow"><div><div class="bg-gray-900 text-white invert-color min-h-screen"><div class="flex flex-col-reverse lg:flex-row lg:h-[calc(100vh_-_65px)] tutorial"><div class="lg:max-w-xl xl:max-w-3xl w-full border-b lg:border-b-0 lg:border-r border-gray-700 flex flex-col"><div class="border-b border-gray-700 pl-8 sticky top-0 flex justify-between items-center bg-gray-900 z-10"><p class="subtitle-sm text-xs text-white/75">Tutorial Instructions</p><button class="border-l border-gray-700 text-sm py-3 px-5 flex items-center gap-4 font-bold"><span>Change Tutorial</span><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="text-white w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M8 9l4-4 4 4m0 6l-4 4-4-4"></path></svg></button></div><div class="max-w-none p-4 sm:p-6 lg:p-8 flex-1 overflow-y-auto"><h1 class="h6 text-primary">Custom data types: DOMAINS</h1><h2 class="h3 mt-4">Why create a custom data type?</h2><p class="body mt-4">Custom data type will help you mostly for data integrity, ensuring your data stored in the database is as you ever wanted it to be. A common <span class="italic">surprise gift</span> relies also in the maintenance of it.</p><p class="body mt-4">With a simple story in this tutorial, you’ll understand how it can help you benefit from those advantages. This tutorial is divided in two sub-tutorials: </p><ul class="list-disc ml-8 mt-4"><li>this part 1 covers DOMAIN usage</li><li>part 2 covers (your own) TYPE usage</li></ul><h2 class="h3 mt-4">Domain usage</h2><p class="body mt-4">Defining your own <span class="italic">domains</span> will be of great usage to prevent insertion of unwanted formatted data or data not corresponding exactly to what you want.</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><code class="language-pgsql !text-sm !bg-gray-800">Command: CREATE DOMAIN Description: define a new domain Syntax: CREATE DOMAIN name [ AS ] data_type [ COLLATE collation ] [ DEFAULT expression ] [ constraint [ ... ] ]</code></pre></div><p class="body mt-4">where constraint is:</p><p class="body mt-4">Related documentation page: <a class="" href="https://www.postgresql.org/docs/14/sql-createdomain.html">https://www.postgresql.org/docs/current/sql-createdomain.html</a></p><h2 class="h3 mt-4">An example worth millions words</h2><p class="body mt-4">Let’s say you have a table <span class="italic">person</span> in your database defined like:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><code class="language-pgsql !text-sm !bg-gray-800">test=# \d person Table &quot;public.person&quot; Column | Type | Collation | Nullable | Default ------------+---------+-----------+----------+------------------------------------ id | integer | | not null | nextval(&#x27;person_id_seq&#x27;::regclass) firstname | text | | not null | lastname | text | | not null | birth_date | date | | | email | text | | not null | Indexes: &quot;person_pkey&quot; PRIMARY KEY, btree (id)create table person</code></pre></div><p class="body mt-4">You notice that the <span class="italic">birth_date </span>can be null, or anything that represents a date, even a date in the 1st century. </p><p class="body mt-4">You notice also that email is a plain text, any text value could fit well here. On production systems, we see that very often, because <span class="italic">CHECKS</span> for data are done inside the application, hoping it does that well for us. A database like PostgreSQL has everything to handle things well, like constraints checking, so why not use this instead? It will allow changing the application from one language to another, first. Second, it will allow usage of the database without going thru the application. In this later case, check constraints are here to prevent any unwanted entry.</p><p class="body mt-4">Let’s say in your application you to insert or update data only of people born after 1920, likely, living persons, and also, you want to be sure that emails stored are likely to be valid.</p><p class="body mt-4"></p><p class="body mt-4">One can easily correct this with some checks in the create table. We could have ALTER-ed the table, but for the clarity of this tutorial, we create a new table instead, as we will do another one after this:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">create table person_using_checks ( id integer generated always as identity primary key , firstname text not null , lastname text not null , birth_date date , email text not null , check (birth_date&gt;&#x27;1930-01-01&#x27;::date) , check (email ~ &#x27;^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$&#x27;) );</code></pre></div><p class="body mt-4">Note that on that example we use the new <code class="">GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY</code> method to create a surrogate key (see <a class="" href="https://www.postgresql.org/docs/15/sql-createtable.htm">https://www.postgresql.org/docs/15/sql-createtable.htm</a> for more details).</p><p class="body mt-4"></p><p class="body mt-4">Once the table is created, try to insert this data:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">insert into person_using_checks (firstname,lastname,birth_date,email) values (&#x27;Jhon&#x27;,&#x27;Doe&#x27;,&#x27;1970-01-01&#x27;::date,&#x27;john@doe.org&#x27;);</code></pre></div><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800"> insert into person_using_checks (firstname,lastname,birth_date,email) values (&#x27;Georges&#x27;,&#x27;Washington&#x27;,&#x27;1732-02-22&#x27;::date,&#x27;georges@whitehouse.gov.us&#x27;);</code></pre></div><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">insert into person_using_checks (firstname,lastname,birth_date,email) values (&#x27;Starman&#x27;,&#x27;Sky&#x27;,&#x27;1972-04-28&#x27;,&#x27;unknown&#x27;);</code></pre></div><p class="body mt-4">On the last 2 examples, PostgreSQL tells you what’s wrong in there…</p><p class="body mt-4"></p><p class="body mt-4">You could let that as it is if you have only that table to manage with this kind of data. But, if you want to apply those checks to other tables, then the best way is to create <span class="italic">domains</span> in PostgreSQL, so you can apply that <span class="italic">domain</span> definition to any table you want where the data has to be the same in your eyes.</p><p class="body mt-4"></p><p class="body mt-4">Let’s create those two domains instead:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">create domain date_of_birth as date check (value &gt; &#x27;1930-01-01&#x27;::date) ; create domain valid_email as text not null check (value ~* &#x27;^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$&#x27;) ;</code></pre></div><p class="body mt-4">Notice that the <span class="italic">date_of_birth</span> domain still allows <span class="italic">null</span> values, but <span class="italic">valid_email</span> doesn’t.</p><p class="body mt-4"></p><p class="body mt-4">You can list your domains in psql with this command:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">\dD</code></pre></div><p class="body mt-4">Once those domains are created, we’ll create a new table using the domains, without the need for extra checks, since those are now done thru the domains:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">create table person_using_domains ( id integer generated always as identity primary key , firstname text not null , lastname text not null , birth_date date_of_birth , email valid_email );</code></pre></div><p class="body mt-4">Try to insert the same data as before, in this new table, and look what happens:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">insert into person_using_domains (firstname,lastname,birth_date,email) values (&#x27;Jhon&#x27;,&#x27;Doe&#x27;,&#x27;1970-01-01&#x27;::date,&#x27;john@doe.org&#x27;);</code></pre></div><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">insert into person_using_domains (firstname,lastname,birth_date,email) values (&#x27;Georges&#x27;,&#x27;Washington&#x27;,&#x27;1732-02-22&#x27;::date,&#x27;georges@whitehouse.gov.us&#x27;);</code></pre></div><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">insert into person_using_domains (firstname,lastname,birth_date,email) values (&#x27;Starman&#x27;,&#x27;Sky&#x27;,&#x27;1972-04-28&#x27;,&#x27;unknown&#x27;);</code></pre></div><p class="body mt-4">PostgreSQL still doesn’t want that data, but the message changed a bit, it refers now to the <span class="italic">domains’</span> constraints.</p><p class="body mt-4"></p><p class="body mt-4">Let’s say the application has now evolved, and we only want to store persons born after 1980.</p><p class="body mt-4">You’ll have first to drop the constraint of the domain and create a new one, because, at least at the moment, PostgreSQL doesn’t allows to modify the check constraints on the fly of a domain (see <a class="" href="https://www.postgresql.org/docs/current/sql-alterdomain.html">https://www.postgresql.org/docs/current/sql-alterdomain.html</a> for complete <span class="italic">ALTER DOMAIN </span>command):</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">alter domain date_of_birth drop constraint date_of_birth_check ;</code></pre></div><p class="body mt-4">If you look at the domain definition in psql, you’ll see there are no more Check listed:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">\dD date_of_birth</code></pre></div><p class="body mt-4">Let’s recreate it now:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">alter domain date_of_birth add check (value &gt; &#x27;1980-01-01&#x27;::date);</code></pre></div><p class="body mt-4">PostgreSQL will refuse, because that <span class="italic">John Doe</span> we inserted was born on epoch 0, i.e. 01/01/1970.. and then, this record doesn’t match <span class="italic">date_of_birth</span> domain requirements.</p><p class="body mt-4"></p><p class="body mt-4">We can enforce this with the “<span class="italic">not valid</span>” in that <span class="italic">alter domain</span>, meaning by PostgreSQL’s documentation : “Do not verify existing stored data for constraint validity”. It’s an enforcement, to let data not satisfying the check of the data live inside our database:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">alter domain date_of_birth add check (value &gt; &#x27;1980-01-01&#x27;::date) not valid;</code></pre></div><p class="body mt-4">By doing this, now we can ask PostgreSQL to check if the check of that particular domain is respected or not:</p><div class="relative"><pre class="rounded-lg mt-6 p-2 text-white !bg-gray-800 border-code"><div class="flex justify-end pb-3 mt-1 mx-1 gap-2"><button class="flex items-center gap-1 uppercase bg-gray-600 hover:bg-gray-500 text-white rounded py-1 px-2 text-sm font-sans w-auto"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="h-4 w-4"><path stroke-linecap="round" stroke-linejoin="round" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path></svg> <!-- -->Copy</button></div><code class="language-pgsql !text-sm !bg-gray-800">alter domain date_of_birth validate constraint date_of_birth_check ;</code></pre></div><p class="body mt-4">It won’t tell which data is violating that “new constraint”. You’ll have to figure it out by yourself, selecting all the data not matching (<span class="italic">where birth_date &lt; ‘1980-01-01’::data …</span>) and then doing what’s necessary to tidy up your database, as an example, creating a person_history table with same columns and moving this data to it, or just deleting it, depending on what you really want to do.</p><p class="body mt-4"></p><p class="body mt-4">Domain should be defined when you’re building your schema. Think well on each column, what kind of domain could it be, what check constraints you want, if it’s null-able or not, if a default value makes sense or not, etc.</p><p class="body mt-4"></p><p class="body mt-4">Too often we see domains are not used, and that’s bad because on any modification of a particular type of data, let’s say <span class="italic">zipcode, </span>one will have to modify any column of the table, one by one, and that’s prone to errors and forgetting that <span class="italic">this particular column </span>in <span class="italic">that particular table</span>, had to be modified too, and one just forgot it… makes it even worse if you have CHECKs in the table’s definition like to validate that a given <span class="italic">zipcode </span>type column is valid: you’ll have to modify each one of those too ! </p><p class="body mt-4"></p><p class="body mt-4">Nowadays, most of tools to create schemas and maintain it will allow you to define your own <span class="italic">domains</span> and manage inside the tool, that will then most likely build a full SQL script for you to create domains, tables, index, etc… Use it ! Your schema readability and maintainability will be really enhanced greatly. </p><aside class="mt-16 bg-black/50 text-white invert-color p-12 rounded-lg shadow-lg text-center flex flex-col items-center border border-gray-700"><h4 class="h4 text-primary">Like our tutorials?</h4><h3 class="h2 mt-3">You&#x27;ll love our newsletter</h3><form method="post" action="/newsletter" class="mt-10 w-full max-w-md"><input type="hidden" name="csrf" value="dda22c84dcbb3a297414dbe678a27db9ca446271ee8eda8f86eb571315c01f42236910a8373c0990b81b864c4315727c4b5ee3d3d657e49a10f1ee0c5d4f61608dda6fcf0144389e5aaa76deda44498c8ca90627b3743e3fd24b086c61d6082e934d9bb7"/><label class="hidden">Do not fill this out please:<!-- --> <input type="text" name="favorite-ice-cream"/></label><label class="hidden">Do not fill this out please, it will be pre-filled:<!-- --> <input type="text" name="favorite-relational-database" value=""/></label><input type="hidden" name="form-loaded-at" value="1740957996680"/><input type="hidden" name="source_url" value="/developers/playground/custom-data-types-domains"/><div class="sm:flex-row flex flex-col gap-4"><div class="min-w-0 flex-1"><label for="email_:R7pd9p:" class="sr-only">Email address</label><input id="email_:R7pd9p:" type="email" name="email" autoComplete="email" class="block w-full border border-gray-200 rounded-md px-5 py-3 text-base text-gray-900 placeholder-gray-500 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-bright focus:ring-opacity-50" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,}" placeholder="Enter your email" aria-invalid="false"/></div><div class="sm:w-auto sm:grow-0 w-full"><button type="submit" class="btn btn-primary w-full"><span class="relative">Join The List</span></button></div></div><div id="form-error-message"></div></form></aside></div></div><div class="flex-1 h-full"><div class="relative h-full w-full"><div class="w-full h-full"></div><div role="status" class="absolute inset-0 bg-gray-900/80 backdrop-blur flex items-center justify-center flex-col text-center"><svg aria-hidden="true" class="w-8 h-8 animate-spin text-gray-600 fill-primary mx-auto mt-12" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"></path><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"></path></svg><p class="body-lg mt-6">Loading terminal...</p></div><div role="status" class="absolute inset-0 bg-gray-900/80 backdrop-blur flex items-center justify-center flex-col text-center"><svg aria-hidden="true" class="w-8 h-8 animate-spin text-gray-600 fill-primary mx-auto mt-12" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"></path><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"></path></svg><p class="body-lg mt-6">Loading terminal...</p></div></div></div></div></div></div></div><footer class="relative bg-slate-950 text-[13px] font-[450] text-blue-100/70 tracking-normal"><div class="absolute inset-0 overflow-hidden pointer-events-none"><svg width="2000" height="3025" viewBox="0 0 1440 3025" fill="none" preserveAspectRatio="none" class="absolute left-0 top-full -translate-y-1/2 [filter:url(#noise-spicy)]"><g filter="url(#footer-filter-:Rh9p:)"><path d="M1766.06 466.544C1766.06 466.544 1766.06 1439.41 720.112 1512.49C-325.835 1585.57 -325.835 2558.44 -325.835 2558.44" stroke="url(#footer-radial-:Rh9p:)" stroke-width="300"></path></g><defs><filter id="footer-filter-:Rh9p:" x="-628.533" y="345.68" width="2697.29" height="2333.62" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur stdDeviation="60" result="effect1_foregroundBlur_458_1273"></feGaussianBlur></filter><filter id="filter_01_footer" x="-520.532" y="453.68" width="2481.29" height="2117.62" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur stdDeviation="6" result="effect1_foregroundBlur_458_1273"></feGaussianBlur></filter><radialGradient id="footer-radial-:Rh9p:" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(838.866 1718.03) rotate(-90) scale(1338.26 1283.46)"><stop offset="0.0479167" stop-color="#2D68FF" stop-opacity="0.50"></stop><stop offset="0.846416" stop-color="#2563EB" stop-opacity="0"></stop></radialGradient></defs></svg></div><div class="relative max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:py-16 lg:px-8"><div class="grid sm:grid-cols-2 lg:flex items-start gap-x-20 gap-y-12 justify-between"><dl><dt class="font-[550] text-blue-500">Products</dt><dd role="list" class="mt-4 grid gap-y-2"><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-high-availability-postgresql">Crunchy Postgres</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-postgresql-for-kubernetes">Crunchy Postgres for Kubernetes</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-bridge">Crunchy Bridge</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-certified-postgresql">Crunchy Certified PostgreSQL</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-postgresql-for-cloud-foundry">Crunchy PostgreSQL for Cloud Foundry</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-mls-postgresql">Crunchy MLS PostgreSQL</a><a class="hocus:text-white transition-colors truncate" href="/products/crunchy-spatial">Crunchy Spatial</a></dd></dl><dl><dt class="font-[550] text-blue-500">Services &amp; Support</dt><dd role="list" class="mt-4 grid gap-y-2"><a class="hocus:text-white transition-colors truncate" href="/solutions/enterprise-postgresql-support">Enterprise PostgreSQL Support</a><a class="hocus:text-white transition-colors truncate" href="/migrate-from-heroku">Migrate from Heroku</a><a class="hocus:text-white transition-colors truncate" href="/solutions/ansible">Ansible</a><a class="hocus:text-white transition-colors truncate" href="/red-hat-certified-technologies">Red Hat Partner</a><a class="hocus:text-white transition-colors truncate" href="/about/postgresql-enterprise-database">Trusted PostgreSQL</a><a class="hocus:text-white transition-colors truncate" href="/about/value-of-subscription">Crunchy Data Subscription</a></dd></dl><dl><dt class="font-[550] text-blue-500">Resources</dt><dd role="list" class="mt-4 grid gap-y-2"><a class="hocus:text-white transition-colors truncate" href="https://access.crunchydata.com">Customer Portal</a><a class="hocus:text-white transition-colors truncate" href="https://access.crunchydata.com/documentation/">Documentation</a><a class="hocus:text-white transition-colors truncate" href="/developers/tutorials">Postgres Tutorials</a><a class="hocus:text-white transition-colors truncate" href="/developers/get-started/fully-managed-postgres">Crunchy Bridge Walkthrough</a><a class="hocus:text-white transition-colors truncate" href="/developers/get-started/postgres-operator">Postgres Operator Walkthrough</a><a class="hocus:text-white transition-colors truncate" href="/blog">Blog</a><a class="hocus:text-white transition-colors truncate" href="/events">Events</a></dd></dl><dl><dt class="font-[550] text-blue-500">Company</dt><dd role="list" class="mt-4 grid gap-y-2"><a class="hocus:text-white transition-colors truncate" href="/about">About</a><a class="hocus:text-white transition-colors truncate" href="/team">Team</a><a class="hocus:text-white transition-colors truncate" href="/news">News</a><a class="hocus:text-white transition-colors truncate" href="/careers">Careers</a><a class="hocus:text-white transition-colors truncate" href="/contact">Contact Us</a><a class="hocus:text-white transition-colors truncate" href="/newsletter">Newsletter</a><a class="hocus:text-white transition-colors truncate" href="/branding">Branding</a><a class="hocus:text-white transition-colors truncate" href="/security">Security</a><a class="hocus:text-white transition-colors truncate" href="/developers/data-collection-notice">Data Collection</a></dd></dl></div><div class="mt-16 grid sm:grid-cols-2 lg:flex justify-between lg:items-end flex-wrap gap-x-20 gap-y-12"><div><p class="max-w-72 text-xs text-balance"><span class="text-blue-500 font-[550]">Subscribe to the Crunchy Data Newsletter</span> <!-- -->and receive Postgres content every month.</p><form method="post" action="/newsletter" class="mt-6 sm:flex"><input type="hidden" name="csrf" value="dda22c84dcbb3a297414dbe678a27db9ca446271ee8eda8f86eb571315c01f42236910a8373c0990b81b864c4315727c4b5ee3d3d657e49a10f1ee0c5d4f61608dda6fcf0144389e5aaa76deda44498c8ca90627b3743e3fd24b086c61d6082e934d9bb7"/><label class="hidden">Do not fill this out please:<!-- --> <input type="text" name="favorite-ice-cream"/></label><label class="hidden">Do not fill this out please, it will be pre-filled:<!-- --> <input type="text" name="favorite-relational-database" value=""/></label><input type="hidden" name="form-loaded-at" value="1740957996681"/><input type="hidden" name="source_url" value="/developers/playground/custom-data-types-domains"/><div class="sm:flex-row flex flex-col gap-4"><div class="min-w-0 flex-1"><label for="email_:R9lh9p:" class="sr-only">Email address</label><input id="email_:R9lh9p:" type="email" name="email" autoComplete="email" class="w-full min-w-0 rounded-lg bg-blue-100/10 px-3.5 py-1.5 text-[13px] text-white border-blue-100/10 hover:border-blue-100/25 focus:border-blue-500/75 sm:w-40 transition-all focus:ring-[3px] focus:ring-blue-500/25 !outline-none" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,}" placeholder="Enter your email" aria-invalid="false"/></div><div class="sm:w-auto sm:grow-0 w-full"><button type="submit" class="button-primary-sm px-3.5 py-2 h-[38px] border-blue-500/50 hocus:border-blue-500/75 after:hidden sm:-ml-1.5"><span class="relative">Subscribe</span></button></div></div><div id="form-error-message"></div></form></div><p class="order-last col-span-full sm:text-center lg:order-none text-[11px] lg:absolute lg:left-1/2 lg:-translate-x-1/2">© 2018-<!-- -->2025<!-- --> Crunchy Data Solutions, Inc.</p><div class="flex flex-col lg:items-end"><div class="flex gap-4 -mr-1 -mt-1"><a href="https://www.youtube.com/c/CrunchyDataPostgres" class="hocus:text-white transition-colors p-1"><span class="sr-only">YouTube</span><svg fill="currentColor" viewBox="0 0 24 24" aria-hidden="true" class="size-4.5"><path fill-rule="evenodd" d="M22.061 6.945a2.629 2.629 0 00-1.856-1.856C18.567 4.65 12 4.65 12 4.65s-6.567 0-8.205.439a2.629 2.629 0 00-1.856 1.856C1.5 8.583 1.5 12 1.5 12s0 3.417.439 5.054a2.628 2.628 0 001.856 1.857c1.638.439 8.205.439 8.205.439s6.567 0 8.205-.439a2.628 2.628 0 001.856-1.857C22.5 15.417 22.5 12 22.5 12s0-3.417-.439-5.055zM9.9 15.15v-6.3L15.356 12 9.9 15.15z" clip-rule="evenodd"></path></svg></a><a href="https://www.linkedin.com/company/crunchy-data-solutions-inc-" class="hocus:text-white transition-colors p-1"><span class="sr-only">LinkedIn</span><svg fill="currentColor" viewBox="0 0 24 24" aria-hidden="true" class="size-4.5"><path fill-rule="evenodd" d="M6.753 20.766h-3.94V8.081h3.94v12.685zM4.781 6.351c-1.26 0-2.281-1.044-2.281-2.303a2.304 2.304 0 012.281-2.282 2.303 2.303 0 012.282 2.282c0 1.259-1.022 2.303-2.282 2.303zM21.5 20.766h-3.935v-6.175c0-1.472-.029-3.359-2.048-3.359-2.048 0-2.362 1.599-2.362 3.253v6.281H9.22V8.081h3.778v1.731h.056c.525-.998 1.81-2.05 3.726-2.05 3.988 0 4.72 2.626 4.72 6.036v6.968z" clip-rule="evenodd"></path></svg></a><a href="https://twitter.com/crunchydata" class="hocus:text-white transition-colors p-1"><span class="sr-only">X</span><svg fill="currentColor" viewBox="0 0 24 24" aria-hidden="true" class="size-4.5"><path d="M13.6823 10.6218L20.2391 3H18.6854L12.9921 9.61788L8.44486 3H3.2002L10.0765 13.0074L3.2002 21H4.75404L10.7663 14.0113L15.5685 21H20.8131L13.6819 10.6218H13.6823ZM11.5541 13.0956L10.8574 12.0991L5.31391 4.16971H7.70053L12.1742 10.5689L12.8709 11.5655L18.6861 19.8835H16.2995L11.5541 13.096V13.0956Z"></path></svg></a><a href="https://github.com/CrunchyData" class="hocus:text-white transition-colors p-1"><span class="sr-only">GitHub</span><svg fill="currentColor" viewBox="0 0 24 24" aria-hidden="true" class="size-4.5"><path fill-rule="evenodd" d="M22 12.925c0 1.329-.133 2.737-.729 3.958C19.692 20.075 15.35 20 12.242 20c-3.159 0-7.759.112-9.4-3.117C2.233 15.675 2 14.254 2 12.925c0-1.746.579-3.396 1.729-4.734a6.51 6.51 0 01-.321-2.033c0-.896.204-1.346.609-2.158 1.887 0 3.095.375 4.533 1.5a15.932 15.932 0 013.696-.417c1.125 0 2.258.121 3.35.383C17.013 4.354 18.221 4 20.088 4c.408.812.608 1.262.608 2.158 0 .683-.108 1.363-.321 2.008C21.521 9.516 22 11.179 22 12.925z"></path></svg></a></div></div></div></div></footer></div><div id="cookiesAlert" style="z-index:2000" class="fixed bottom-0 left-0 w-full flex justify-between items-center bg-gradient text-white invert-color py-2 px-4" role="alert"><p class="body">This site uses cookies for usage analytics to improve our service. By continuing to browse this site, you agree to this use. See our <a href="/privacy">privacy policy</a> to learn more.</p><form method="post" action="/?redirectTo=https%3A%2F%2Fwww.crunchydata.com%2Fdevelopers%2Fplayground%2Fcustom-data-types-domains"><input type="hidden" name="acknowledged" value="true"/><button type="submit" class="p-1 hover:bg-white hover:bg-opacity-10 rounded" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg></button></form></div><script>((STORAGE_KEY, restoreKey) => { if (!window.history.state || !window.history.state.key) { let key = Math.random().toString(32).slice(2); window.history.replaceState({ key }, ""); } try { let positions = JSON.parse(sessionStorage.getItem(STORAGE_KEY) || "{}"); let storedY = positions[restoreKey || window.history.state.key]; if (typeof storedY === "number") { window.scrollTo(0, storedY); } } catch (error) { console.error(error); sessionStorage.removeItem(STORAGE_KEY); } })("positions", null)</script><script src="https://link.crunchydata.com/cd.js"></script><script type="text/javascript" id="hs-script-loader" async="" defer="" src="https://js.hs-scripts.com/2283855.js"></script><script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-92590099-1"></script><script id="gtag-init"> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-92590099-1', { page_path: window.location.pathname }); </script><script>window.ENV = {"SENTRY_DSN":"https://559dc1e9c3fb4e0c975085672c7cab7d@o433451.ingest.sentry.io/6653378"}</script><link rel="modulepreload" href="/build/entry.client-DNLNFP27.js"/><link rel="modulepreload" href="/build/_shared/chunk-TCLGSVZV.js"/><link rel="modulepreload" href="/build/_shared/chunk-SCPVB2C3.js"/><link rel="modulepreload" href="/build/_shared/chunk-R5E7U4V6.js"/><link rel="modulepreload" href="/build/_shared/chunk-CKGZT7DU.js"/><link rel="modulepreload" href="/build/_shared/chunk-E5ZSF32D.js"/><link rel="modulepreload" href="/build/_shared/chunk-MVES7OWQ.js"/><link rel="modulepreload" href="/build/_shared/chunk-SQO6Y7LN.js"/><link rel="modulepreload" href="/build/_shared/chunk-HDHVBSWO.js"/><link rel="modulepreload" href="/build/_shared/chunk-ASHQKMRQ.js"/><link rel="modulepreload" href="/build/_shared/chunk-DRSE3CTB.js"/><link rel="modulepreload" href="/build/_shared/chunk-CF2UHLZU.js"/><link rel="modulepreload" href="/build/_shared/chunk-S3UTQVRD.js"/><link rel="modulepreload" href="/build/_shared/chunk-LSEESZC2.js"/><link rel="modulepreload" href="/build/_shared/chunk-WV5TGDCL.js"/><link rel="modulepreload" href="/build/_shared/chunk-IV5M4NBL.js"/><link rel="modulepreload" href="/build/_shared/chunk-VBCR3HLH.js"/><link rel="modulepreload" href="/build/_shared/chunk-5LDDUBXY.js"/><link rel="modulepreload" href="/build/root-IFB3O6XU.js"/><link rel="modulepreload" href="/build/_shared/chunk-QAF2GV3M.js"/><link rel="modulepreload" href="/build/_shared/chunk-JZ33HRWW.js"/><link rel="modulepreload" href="/build/routes/developers-US4DTEXN.js"/><link rel="modulepreload" href="/build/routes/developers/playground-D6ZVM7CW.js"/><link rel="modulepreload" href="/build/_shared/chunk-27D73SZ2.js"/><link rel="modulepreload" href="/build/_shared/chunk-C2YZCCVO.js"/><link rel="modulepreload" href="/build/_shared/chunk-N2KCTWJH.js"/><link rel="modulepreload" href="/build/_shared/chunk-TBAP37XV.js"/><link rel="modulepreload" href="/build/_shared/chunk-VPACOEBH.js"/><link rel="modulepreload" href="/build/_shared/chunk-74KVKBNK.js"/><link rel="modulepreload" href="/build/_shared/chunk-I2ET5AXY.js"/><link rel="modulepreload" href="/build/routes/developers/playground/$slug-OOU3YVCU.js"/><script>window.__remixContext = {"url":"/developers/playground/custom-data-types-domains","state":{"loaderData":{"root":{"domain":"https://www.crunchydata.com","canonicalUrl":"https://www.crunchydata.com/developers/playground/custom-data-types-domains","expectedUrl":"https://www.crunchydata.com/developers/playground/custom-data-types-domains","anonId":"vwfffdhrktkdacbxnlsbdfrwungiinssdvgphacklanqsopax","csrf":"dda22c84dcbb3a297414dbe678a27db9ca446271ee8eda8f86eb571315c01f42236910a8373c0990b81b864c4315727c4b5ee3d3d657e49a10f1ee0c5d4f61608dda6fcf0144389e5aaa76deda44498c8ca90627b3743e3fd24b086c61d6082e934d9bb7","acknowledged":false,"loadScripts":true,"ENV":{"SENTRY_DSN":"https://559dc1e9c3fb4e0c975085672c7cab7d@o433451.ingest.sentry.io/6653378"},"sentryTrace":"c80fe0356ac44b27878e2e79489e924a-a36e0b9b02db4628-0","sentryBaggage":"sentry-environment=production,sentry-public_key=559dc1e9c3fb4e0c975085672c7cab7d,sentry-trace_id=c80fe0356ac44b27878e2e79489e924a,sentry-sample_rate=0.05,sentry-transaction=routes%2Fdevelopers%2Fplayground%2F%24slug,sentry-sampled=false","remixVersion":1},"routes/developers/playground/$slug":{"tutorial":{"uid":"c671b0ea-fa73-4ed7-8b41-80da3438e758","title":"Custom data types: DOMAINS","slug":"custom-data-types-domains","published":true,"description":"Learn about user-defined datatypes, domain types, and how to create constraints that validate values.","dataUrl":"","vmMemory":"","blocks":[{"object":"block","id":"f07557ec-fd18-470d-9553-e8a55c27e0c5","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"heading_2","heading_2":{"rich_text":[{"type":"text","text":{"content":"Why create a custom data type?","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Why create a custom data type?","href":null}],"is_toggleable":false,"color":"default"}},{"object":"block","id":"30b7d453-1dfe-4e87-8c57-fbd7ce237bec","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Custom data type will help you mostly for data integrity, ensuring your data stored in the database is as you ever wanted it to be. A common ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Custom data type will help you mostly for data integrity, ensuring your data stored in the database is as you ever wanted it to be. A common ","href":null},{"type":"text","text":{"content":"surprise gift","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"surprise gift","href":null},{"type":"text","text":{"content":" relies also in the maintenance of it.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" relies also in the maintenance of it.","href":null}],"color":"default"}},{"object":"block","id":"d0967798-4fe1-47fe-bcae-61baf202e487","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"With a simple story in this tutorial, you’ll understand how it can help you benefit from those advantages. This tutorial is divided in two sub-tutorials: ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"With a simple story in this tutorial, you’ll understand how it can help you benefit from those advantages. This tutorial is divided in two sub-tutorials: ","href":null}],"color":"default"}},{"id":"virtual-bulleted-list-3","type":"bulleted_list","bulleted_list":{},"has_children":true,"children":[{"object":"block","id":"20e65152-e876-4120-84e6-8b8767d1353c","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"bulleted_list_item","bulleted_list_item":{"rich_text":[{"type":"text","text":{"content":"this part 1 covers DOMAIN usage","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"this part 1 covers DOMAIN usage","href":null}],"color":"default"}},{"object":"block","id":"1f76ced2-d482-4fe7-be96-f5a396c28c41","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"bulleted_list_item","bulleted_list_item":{"rich_text":[{"type":"text","text":{"content":"part 2 covers (your own) TYPE usage","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"part 2 covers (your own) TYPE usage","href":null}],"color":"default"}}]},{"object":"block","id":"e5441595-a9e9-41ae-929e-5431ee55c4c4","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"heading_2","heading_2":{"rich_text":[{"type":"text","text":{"content":"Domain usage","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Domain usage","href":null}],"is_toggleable":false,"color":"default"}},{"object":"block","id":"6991d844-5fff-495c-bdd7-c8ef0975a994","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Defining your own ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Defining your own ","href":null},{"type":"text","text":{"content":"domains","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"domains","href":null},{"type":"text","text":{"content":" will be of great usage to prevent insertion of unwanted formatted data or data not corresponding exactly to what you want.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" will be of great usage to prevent insertion of unwanted formatted data or data not corresponding exactly to what you want.","href":null}],"color":"default"}},{"object":"block","id":"39e87d44-c720-47b9-a6b2-a68c89e44906","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-18T14:23:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[{"type":"text","text":{"content":"nocopy","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"nocopy","href":null}],"rich_text":[{"type":"text","text":{"content":"Command: CREATE DOMAIN\nDescription: define a new domain\nSyntax:\nCREATE DOMAIN name [ AS ] data_type\n\t[ COLLATE collation ]\n\t[ DEFAULT expression ]\n\t[ constraint [ ... ] ]","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Command: CREATE DOMAIN\nDescription: define a new domain\nSyntax:\nCREATE DOMAIN name [ AS ] data_type\n\t[ COLLATE collation ]\n\t[ DEFAULT expression ]\n\t[ constraint [ ... ] ]","href":null}],"language":"sql"}},{"object":"block","id":"0c177676-e2f3-48ce-b9f5-965baef9492d","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":true,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"where constraint is:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"where constraint is:","href":null}],"color":"default"},"children":[{"object":"block","id":"54f798ce-095d-48d3-bb28-ff82e7757abe","parent":{"type":"block_id","block_id":"0c177676-e2f3-48ce-b9f5-965baef9492d"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-18T14:23:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[{"type":"text","text":{"content":"nocopy","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"nocopy","href":null}],"rich_text":[{"type":"text","text":{"content":"[ CONSTRAINT constraint_name ]\n{ NOT NULL | NULL | CHECK (expression) }","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"[ CONSTRAINT constraint_name ]\n{ NOT NULL | NULL | CHECK (expression) }","href":null}],"language":"sql"}}]},{"object":"block","id":"9e16e51d-558c-4f5f-8c5b-e66c257a3d5f","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Related documentation page: ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Related documentation page: ","href":null},{"type":"text","text":{"content":"https://www.postgresql.org/docs/current/sql-createdomain.html","link":{"url":"https://www.postgresql.org/docs/14/sql-createdomain.html"}},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"https://www.postgresql.org/docs/current/sql-createdomain.html","href":"https://www.postgresql.org/docs/14/sql-createdomain.html"}],"color":"default"}},{"object":"block","id":"b1d2b8fe-003e-4565-a850-54d5dda10dfc","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"heading_2","heading_2":{"rich_text":[{"type":"text","text":{"content":"An example worth millions words","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"An example worth millions words","href":null}],"is_toggleable":false,"color":"default"}},{"object":"block","id":"40f46781-c625-4325-9ad1-2680d5780152","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Let’s say you have a table ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Let’s say you have a table ","href":null},{"type":"text","text":{"content":"person","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"person","href":null},{"type":"text","text":{"content":" in your database defined like:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" in your database defined like:","href":null}],"color":"default"}},{"object":"block","id":"0649b3d6-62e1-4ef7-b409-37a41533f99f","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-18T14:23:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[{"type":"text","text":{"content":"nocopy","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"nocopy","href":null}],"rich_text":[{"type":"text","text":{"content":"test=# \\d person\n Table \"public.person\"\n Column | Type | Collation | Nullable | Default \n------------+---------+-----------+----------+------------------------------------\n id | integer | | not null | nextval('person_id_seq'::regclass)\n firstname | text | | not null | \n lastname | text | | not null | \n birth_date | date | | | \n email | text | | not null | \nIndexes:\n \"person_pkey\" PRIMARY KEY, btree (id)create table person","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"test=# \\d person\n Table \"public.person\"\n Column | Type | Collation | Nullable | Default \n------------+---------+-----------+----------+------------------------------------\n id | integer | | not null | nextval('person_id_seq'::regclass)\n firstname | text | | not null | \n lastname | text | | not null | \n birth_date | date | | | \n email | text | | not null | \nIndexes:\n \"person_pkey\" PRIMARY KEY, btree (id)create table person","href":null}],"language":"sql"}},{"object":"block","id":"5054207d-5698-47eb-9c81-46ee9a312f0d","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"You notice that the ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"You notice that the ","href":null},{"type":"text","text":{"content":"birth_date ","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"birth_date ","href":null},{"type":"text","text":{"content":"can be null, or anything that represents a date, even a date in the 1st century. ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"can be null, or anything that represents a date, even a date in the 1st century. ","href":null}],"color":"default"}},{"object":"block","id":"d8c1d482-9b84-4f3b-8381-5691848a684b","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"You notice also that email is a plain text, any text value could fit well here. On production systems, we see that very often, because ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"You notice also that email is a plain text, any text value could fit well here. On production systems, we see that very often, because ","href":null},{"type":"text","text":{"content":"CHECKS","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"CHECKS","href":null},{"type":"text","text":{"content":" for data are done inside the application, hoping it does that well for us. A database like PostgreSQL has everything to handle things well, like constraints checking, so why not use this instead? It will allow changing the application from one language to another, first. Second, it will allow usage of the database without going thru the application. In this later case, check constraints are here to prevent any unwanted entry.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" for data are done inside the application, hoping it does that well for us. A database like PostgreSQL has everything to handle things well, like constraints checking, so why not use this instead? It will allow changing the application from one language to another, first. Second, it will allow usage of the database without going thru the application. In this later case, check constraints are here to prevent any unwanted entry.","href":null}],"color":"default"}},{"object":"block","id":"ea14ffcf-f758-48f4-ad54-cca75d2dc356","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Let’s say in your application you to insert or update data only of people born after 1920, likely, living persons, and also, you want to be sure that emails stored are likely to be valid.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Let’s say in your application you to insert or update data only of people born after 1920, likely, living persons, and also, you want to be sure that emails stored are likely to be valid.","href":null}],"color":"default"}},{"object":"block","id":"98bef11c-58da-4272-8f4b-d7cee9fc707a","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"264cbc11-917a-4a48-9d76-561638a56c87","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"One can easily correct this with some checks in the create table. We could have ALTER-ed the table, but for the clarity of this tutorial, we create a new table instead, as we will do another one after this:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"One can easily correct this with some checks in the create table. We could have ALTER-ed the table, but for the clarity of this tutorial, we create a new table instead, as we will do another one after this:","href":null}],"color":"default"}},{"object":"block","id":"70578a3f-f404-4ecf-9834-f0b394f6e08e","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:41:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"create table person_using_checks (\n id integer generated always as identity primary key\n , firstname text not null\n , lastname text not null\n , birth_date date\n , email text not null\n , check (birth_date\u003e'1930-01-01'::date)\n , check (email ~ '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$')\n);","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"create table person_using_checks (\n id integer generated always as identity primary key\n , firstname text not null\n , lastname text not null\n , birth_date date\n , email text not null\n , check (birth_date\u003e'1930-01-01'::date)\n , check (email ~ '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$')\n);","href":null}],"language":"sql"}},{"object":"block","id":"3d52f356-f854-4739-b10f-e3268f2ee186","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:39:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Note that on that example we use the new ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Note that on that example we use the new ","href":null},{"type":"text","text":{"content":"GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":true,"color":"default"},"plain_text":"GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY","href":null},{"type":"text","text":{"content":" method to create a surrogate key (see ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" method to create a surrogate key (see ","href":null},{"type":"text","text":{"content":"https://www.postgresql.org/docs/15/sql-createtable.htm","link":{"url":"https://www.postgresql.org/docs/15/sql-createtable.htm"}},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"https://www.postgresql.org/docs/15/sql-createtable.htm","href":"https://www.postgresql.org/docs/15/sql-createtable.htm"},{"type":"text","text":{"content":" for more details).","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" for more details).","href":null}],"color":"default"}},{"object":"block","id":"78a1de36-094e-409a-8f22-34dca21e36ff","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-11-14T09:39:00.000Z","last_edited_time":"2022-11-14T09:39:00.000Z","created_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"7fc67b75-61a9-49b8-a5fd-03399126a80b","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:36:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Once the table is created, try to insert this data:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Once the table is created, try to insert this data:","href":null}],"color":"default"}},{"object":"block","id":"d329606d-6254-4f30-ae82-761919d2d365","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"insert into person_using_checks (firstname,lastname,birth_date,email) \nvalues ('Jhon','Doe','1970-01-01'::date,'john@doe.org');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"insert into person_using_checks (firstname,lastname,birth_date,email) \nvalues ('Jhon','Doe','1970-01-01'::date,'john@doe.org');","href":null}],"language":"sql"}},{"object":"block","id":"443e408e-7d05-4149-b64b-2e507f0e1b84","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":" insert into person_using_checks (firstname,lastname,birth_date,email)\n values ('Georges','Washington','1732-02-22'::date,'georges@whitehouse.gov.us');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" insert into person_using_checks (firstname,lastname,birth_date,email)\n values ('Georges','Washington','1732-02-22'::date,'georges@whitehouse.gov.us');","href":null}],"language":"sql"}},{"object":"block","id":"26215dc8-d2c5-45fd-a8f2-9bc4ac8a2caf","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"insert into person_using_checks (firstname,lastname,birth_date,email)\nvalues ('Starman','Sky','1972-04-28','unknown');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"insert into person_using_checks (firstname,lastname,birth_date,email)\nvalues ('Starman','Sky','1972-04-28','unknown');","href":null}],"language":"sql"}},{"object":"block","id":"74b2462a-0ca2-4f0d-9fed-178be2456f41","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"On the last 2 examples, PostgreSQL tells you what’s wrong in there…","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"On the last 2 examples, PostgreSQL tells you what’s wrong in there…","href":null}],"color":"default"}},{"object":"block","id":"6fda89c1-d44e-4c9d-b6fe-3076f1f20b02","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"9ee0a3f7-b1c1-4807-9f98-c4be95bcd613","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"You could let that as it is if you have only that table to manage with this kind of data. But, if you want to apply those checks to other tables, then the best way is to create ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"You could let that as it is if you have only that table to manage with this kind of data. But, if you want to apply those checks to other tables, then the best way is to create ","href":null},{"type":"text","text":{"content":"domains","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"domains","href":null},{"type":"text","text":{"content":" in PostgreSQL, so you can apply that ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" in PostgreSQL, so you can apply that ","href":null},{"type":"text","text":{"content":"domain","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"domain","href":null},{"type":"text","text":{"content":" definition to any table you want where the data has to be the same in your eyes.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" definition to any table you want where the data has to be the same in your eyes.","href":null}],"color":"default"}},{"object":"block","id":"05454a88-c05b-4fae-a979-c58793fed6ea","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"a6dd2135-a320-4ba7-9683-f7ed43b4f545","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Let’s create those two domains instead:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Let’s create those two domains instead:","href":null}],"color":"default"}},{"object":"block","id":"8ad0ecb9-49f1-411d-9c47-3db7a1bca2e8","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"create domain date_of_birth as date\n\tcheck (value \u003e '1930-01-01'::date)\n;\ncreate domain valid_email as text\n\tnot null\n\tcheck (value ~* '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$')\n;","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"create domain date_of_birth as date\n\tcheck (value \u003e '1930-01-01'::date)\n;\ncreate domain valid_email as text\n\tnot null\n\tcheck (value ~* '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$')\n;","href":null}],"language":"sql"}},{"object":"block","id":"0332e86b-0220-4097-8a4e-c161b027408b","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Notice that the ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Notice that the ","href":null},{"type":"text","text":{"content":"date_of_birth","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"date_of_birth","href":null},{"type":"text","text":{"content":" domain still allows ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" domain still allows ","href":null},{"type":"text","text":{"content":"null","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"null","href":null},{"type":"text","text":{"content":" values, but ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" values, but ","href":null},{"type":"text","text":{"content":"valid_email","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"valid_email","href":null},{"type":"text","text":{"content":" doesn’t.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" doesn’t.","href":null}],"color":"default"}},{"object":"block","id":"81a2696b-49a1-4517-914c-78c6b0351b84","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-11-14T09:45:00.000Z","last_edited_time":"2022-11-14T09:47:00.000Z","created_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"875ebe3e-eb86-4379-93fa-35b94bd31222","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-11-14T09:45:00.000Z","last_edited_time":"2022-11-14T09:47:00.000Z","created_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"You can list your domains in psql with this command:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"You can list your domains in psql with this command:","href":null}],"color":"default"}},{"object":"block","id":"076ab555-8b61-49ca-9bd8-55e19f74a9de","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-11-14T09:47:00.000Z","last_edited_time":"2022-11-14T09:48:00.000Z","created_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"\\dD","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"\\dD","href":null}],"language":"sql"}},{"object":"block","id":"40ef07f7-099e-4303-9924-1fc847d0694e","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:48:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Once those domains are created, we’ll create a new table using the domains, without the need for extra checks, since those are now done thru the domains:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Once those domains are created, we’ll create a new table using the domains, without the need for extra checks, since those are now done thru the domains:","href":null}],"color":"default"}},{"object":"block","id":"076f0544-aa2b-4209-95fb-b7bb72df7934","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:43:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"create table person_using_domains (\n id integer generated always as identity primary key\n, firstname text not null\n, lastname text not null\n, birth_date date_of_birth\n, email valid_email\n);","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"create table person_using_domains (\n id integer generated always as identity primary key\n, firstname text not null\n, lastname text not null\n, birth_date date_of_birth\n, email valid_email\n);","href":null}],"language":"sql"}},{"object":"block","id":"c2219de0-fb55-4e41-aa28-a875d3024cc2","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Try to insert the same data as before, in this new table, and look what happens:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Try to insert the same data as before, in this new table, and look what happens:","href":null}],"color":"default"}},{"object":"block","id":"d052f09d-6d73-4d7c-9ab3-1e1b79108256","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:44:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"insert into person_using_domains (firstname,lastname,birth_date,email) \nvalues ('Jhon','Doe','1970-01-01'::date,'john@doe.org');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"insert into person_using_domains (firstname,lastname,birth_date,email) \nvalues ('Jhon','Doe','1970-01-01'::date,'john@doe.org');","href":null}],"language":"sql"}},{"object":"block","id":"5bb54e49-733b-493a-a0ab-02b2af94b18e","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:44:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"insert into person_using_domains (firstname,lastname,birth_date,email)\nvalues ('Georges','Washington','1732-02-22'::date,'georges@whitehouse.gov.us');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"insert into person_using_domains (firstname,lastname,birth_date,email)\nvalues ('Georges','Washington','1732-02-22'::date,'georges@whitehouse.gov.us');","href":null}],"language":"sql"}},{"object":"block","id":"e26b3e80-fd5e-4361-93f2-9a5a6ac783dc","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-11-14T09:44:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"15a63a21-c195-448c-97b3-4ac219550235"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"insert into person_using_domains (firstname,lastname,birth_date,email)\nvalues ('Starman','Sky','1972-04-28','unknown');","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"insert into person_using_domains (firstname,lastname,birth_date,email)\nvalues ('Starman','Sky','1972-04-28','unknown');","href":null}],"language":"sql"}},{"object":"block","id":"3abbf4a9-26ad-479b-b8eb-8baaf87a128b","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"PostgreSQL still doesn’t want that data, but the message changed a bit, it refers now to the ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"PostgreSQL still doesn’t want that data, but the message changed a bit, it refers now to the ","href":null},{"type":"text","text":{"content":"domains’","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"domains’","href":null},{"type":"text","text":{"content":" constraints.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" constraints.","href":null}],"color":"default"}},{"object":"block","id":"0be520e1-770b-4882-9b39-68ffcbb73a7f","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"94321bda-0f15-4c95-8a45-de899ec4c152","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Let’s say the application has now evolved, and we only want to store persons born after 1980.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Let’s say the application has now evolved, and we only want to store persons born after 1980.","href":null}],"color":"default"}},{"object":"block","id":"b096860a-ec42-43eb-8953-298fb6da36da","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"You’ll have first to drop the constraint of the domain and create a new one, because, at least at the moment, PostgreSQL doesn’t allows to modify the check constraints on the fly of a domain (see ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"You’ll have first to drop the constraint of the domain and create a new one, because, at least at the moment, PostgreSQL doesn’t allows to modify the check constraints on the fly of a domain (see ","href":null},{"type":"text","text":{"content":"https://www.postgresql.org/docs/current/sql-alterdomain.html","link":{"url":"https://www.postgresql.org/docs/current/sql-alterdomain.html"}},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"https://www.postgresql.org/docs/current/sql-alterdomain.html","href":"https://www.postgresql.org/docs/current/sql-alterdomain.html"},{"type":"text","text":{"content":" for complete ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" for complete ","href":null},{"type":"text","text":{"content":"ALTER DOMAIN ","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"ALTER DOMAIN ","href":null},{"type":"text","text":{"content":"command):","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"command):","href":null}],"color":"default"}},{"object":"block","id":"e7057a45-7d2b-4789-85e0-57a411c4a0a1","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"alter domain date_of_birth drop constraint date_of_birth_check ;","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"alter domain date_of_birth drop constraint date_of_birth_check ;","href":null}],"language":"sql"}},{"object":"block","id":"8074298b-ec5e-44ce-bcf4-1e9eed763b18","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"If you look at the domain definition in psql, you’ll see there are no more Check listed:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"If you look at the domain definition in psql, you’ll see there are no more Check listed:","href":null}],"color":"default"}},{"object":"block","id":"ba2ad998-6483-4776-8265-73f6fc7a949e","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"\\dD date_of_birth","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"\\dD date_of_birth","href":null}],"language":"sql"}},{"object":"block","id":"da3df1fd-105b-45b2-aa32-4625ae112d76","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Let’s recreate it now:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Let’s recreate it now:","href":null}],"color":"default"}},{"object":"block","id":"98e733c8-2e79-4133-8333-ba9bf750b649","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"alter domain date_of_birth add check (value \u003e '1980-01-01'::date);","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"alter domain date_of_birth add check (value \u003e '1980-01-01'::date);","href":null}],"language":"sql"}},{"object":"block","id":"34738ffb-1cf5-4e02-891c-262c52d296ec","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"PostgreSQL will refuse, because that ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"PostgreSQL will refuse, because that ","href":null},{"type":"text","text":{"content":"John Doe","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"John Doe","href":null},{"type":"text","text":{"content":" we inserted was born on epoch 0, i.e. 01/01/1970.. and then, this record doesn’t match ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" we inserted was born on epoch 0, i.e. 01/01/1970.. and then, this record doesn’t match ","href":null},{"type":"text","text":{"content":"date_of_birth","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"date_of_birth","href":null},{"type":"text","text":{"content":" domain requirements.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" domain requirements.","href":null}],"color":"default"}},{"object":"block","id":"d80cf6e8-85fc-49cb-9d1d-42b59f7dea8a","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"ead1031e-6f6b-40c0-b080-07693e20b50e","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"We can enforce this with the “","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"We can enforce this with the “","href":null},{"type":"text","text":{"content":"not valid","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"not valid","href":null},{"type":"text","text":{"content":"” in that ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"” in that ","href":null},{"type":"text","text":{"content":"alter domain","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"alter domain","href":null},{"type":"text","text":{"content":", meaning by PostgreSQL’s documentation : “Do not verify existing stored data for constraint validity”. It’s an enforcement, to let data not satisfying the check of the data live inside our database:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":", meaning by PostgreSQL’s documentation : “Do not verify existing stored data for constraint validity”. It’s an enforcement, to let data not satisfying the check of the data live inside our database:","href":null}],"color":"default"}},{"object":"block","id":"1c92247d-2c9f-4aa7-a3dd-39aa32b82f80","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"alter domain date_of_birth add check (value \u003e '1980-01-01'::date) not valid;","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"alter domain date_of_birth add check (value \u003e '1980-01-01'::date) not valid;","href":null}],"language":"sql"}},{"object":"block","id":"04d3deda-0784-41be-8c10-4c0f14d11c28","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"By doing this, now we can ask PostgreSQL to check if the check of that particular domain is respected or not:","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"By doing this, now we can ask PostgreSQL to check if the check of that particular domain is respected or not:","href":null}],"color":"default"}},{"object":"block","id":"e473ded0-b0fa-4117-bf8a-5962bbf22284","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"code","code":{"caption":[],"rich_text":[{"type":"text","text":{"content":"alter domain date_of_birth validate constraint date_of_birth_check ;","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"alter domain date_of_birth validate constraint date_of_birth_check ;","href":null}],"language":"sql"}},{"object":"block","id":"48bca47c-2014-4354-94e3-0352c2478bc5","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"It won’t tell which data is violating that “new constraint”. You’ll have to figure it out by yourself, selecting all the data not matching (","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"It won’t tell which data is violating that “new constraint”. You’ll have to figure it out by yourself, selecting all the data not matching (","href":null},{"type":"text","text":{"content":"where birth_date \u003c ‘1980-01-01’::data …","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"where birth_date \u003c ‘1980-01-01’::data …","href":null},{"type":"text","text":{"content":") and then doing what’s necessary to tidy up your database, as an example, creating a person_history table with same columns and moving this data to it, or just deleting it, depending on what you really want to do.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":") and then doing what’s necessary to tidy up your database, as an example, creating a person_history table with same columns and moving this data to it, or just deleting it, depending on what you really want to do.","href":null}],"color":"default"}},{"object":"block","id":"0c73ed51-238d-40e9-908d-3c0497880efa","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"8fbc660c-a8d3-4552-aaae-37bfa30de6e6","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Domain should be defined when you’re building your schema. Think well on each column, what kind of domain could it be, what check constraints you want, if it’s null-able or not, if a default value makes sense or not, etc.","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Domain should be defined when you’re building your schema. Think well on each column, what kind of domain could it be, what check constraints you want, if it’s null-able or not, if a default value makes sense or not, etc.","href":null}],"color":"default"}},{"object":"block","id":"dba5021d-23ff-4e08-b209-a42d57284070","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"0c82381a-fcc4-4481-8310-15a29f8c75d9","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Too often we see domains are not used, and that’s bad because on any modification of a particular type of data, let’s say ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Too often we see domains are not used, and that’s bad because on any modification of a particular type of data, let’s say ","href":null},{"type":"text","text":{"content":"zipcode, ","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"zipcode, ","href":null},{"type":"text","text":{"content":"one will have to modify any column of the table, one by one, and that’s prone to errors and forgetting that ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"one will have to modify any column of the table, one by one, and that’s prone to errors and forgetting that ","href":null},{"type":"text","text":{"content":"this particular column ","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"this particular column ","href":null},{"type":"text","text":{"content":"in ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"in ","href":null},{"type":"text","text":{"content":"that particular table","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"that particular table","href":null},{"type":"text","text":{"content":", had to be modified too, and one just forgot it… makes it even worse if you have CHECKs in the table’s definition like to validate that a given ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":", had to be modified too, and one just forgot it… makes it even worse if you have CHECKs in the table’s definition like to validate that a given ","href":null},{"type":"text","text":{"content":"zipcode ","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"zipcode ","href":null},{"type":"text","text":{"content":"type column is valid: you’ll have to modify each one of those too ! ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"type column is valid: you’ll have to modify each one of those too ! ","href":null}],"color":"default"}},{"object":"block","id":"74826e4f-1a45-4ca5-b8dd-cb64a4a919ee","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[],"color":"default"}},{"object":"block","id":"0740d99c-7405-46f7-b201-fcab3dfa7db7","parent":{"type":"page_id","page_id":"c671b0ea-fa73-4ed7-8b41-80da3438e758"},"created_time":"2022-10-17T21:45:00.000Z","last_edited_time":"2022-10-17T21:45:00.000Z","created_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"last_edited_by":{"object":"user","id":"9a84d548-ec10-47d5-be3f-d8a1fb285e61"},"has_children":false,"archived":false,"in_trash":false,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"Nowadays, most of tools to create schemas and maintain it will allow you to define your own ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Nowadays, most of tools to create schemas and maintain it will allow you to define your own ","href":null},{"type":"text","text":{"content":"domains","link":null},"annotations":{"bold":false,"italic":true,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"domains","href":null},{"type":"text","text":{"content":" and manage inside the tool, that will then most likely build a full SQL script for you to create domains, tables, index, etc… Use it ! Your schema readability and maintainability will be really enhanced greatly. ","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":" and manage inside the tool, that will then most likely build a full SQL script for you to create domains, tables, index, etc… Use it ! Your schema readability and maintainability will be really enhanced greatly. ","href":null}],"color":"default"}}]}},"routes/developers":null,"routes/developers/playground":null},"actionData":null,"errors":null},"future":{"v2_dev":false,"unstable_postcss":false,"unstable_tailwind":false,"v2_errorBoundary":false,"v2_headers":false,"v2_meta":true,"v2_normalizeFormMethod":false,"v2_routeConvention":false}};</script><script type="module" async="">import "/build/manifest-A43C69B9.js"; import * as route0 from "/build/root-IFB3O6XU.js"; import * as route1 from "/build/routes/developers-US4DTEXN.js"; import * as route2 from "/build/routes/developers/playground-D6ZVM7CW.js"; import * as route3 from "/build/routes/developers/playground/$slug-OOU3YVCU.js"; window.__remixRouteModules = {"root":route0,"routes/developers":route1,"routes/developers/playground":route2,"routes/developers/playground/$slug":route3}; import("/build/entry.client-DNLNFP27.js");</script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10