# Contract translation for use in an external system

**URL:** <https://racket.discourse.group/t/contract-translation-for-use-in-an-external-system/444>\
**Category:** Questions & Answers\
**Tags:** contract\
**Created:** [December 19, 2021, 3:22pm UTC](https://racket.discourse.group/t/contract-translation-for-use-in-an-external-system/444 "2021-12-19T15:22:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rscho](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/rscho/32/726_2.png) [@rscho](https://racket.discourse.group/u/rscho)\
**Post date:** [December 19, 2021, 3:22pm UTC](https://racket.discourse.group/t/contract-translation-for-use-in-an-external-system/444/1 "2021-12-19T15:22:01Z")

</div>

Hi,

I'd like to mirror Racket contracts on the SQLite side for a proof-of-concept dataframe library. Any type can be inserted in any column in SQLite, although types can optionally be enforced at runtime through triggers and `CHECK` constraints.

So conceptually, here's a brief depiction of what I have up to now:

A dataframe is a (possibly dependently) contracted `struct`

```scheme
#lang racket

(struct df (col1 col2 col3))

(define dataframe
 (struct/dc df
                    [col1 any/c]
                    [col2 (col1) (>/c col1)]
                    [col3 (col1 col2) (between/c col1 col2)]))

```

From there, I'm doing some very brittle parsing of the contract to construct SQLite triggers.

Now, except when running `SELECT` statements, I don't materialize any data on the Racket side. Everything stays in the database so I've no real need for `df` itself since it will never be instantiated. I only need the contract!

What would be a good way to reflect Racket contracts on the SQLite side in a consistent manner?

I hope I'm making at least a little sense... 😅
