Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)
Дата
Msg-id CAKFQuwbH0sB8Rc0LMV77fUkP9c-foqEfzCCDLSusTfaG933Jvw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)  (Rui DeSousa <rui@crazybean.net>)
Ответы Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)
Список pgsql-admin
On Tuesday, April 28, 2020, Rui DeSousa <rui@crazybean.net> wrote:

Arbitrarily? What’s a cusip, vin, ssn?  Why would you put a btree index on a text field? Because it’s not.

What you’re advocating is a NoSQL design — defer your schema design.  Letting the application code littered in multiple places elsewhere define what a cusip, etc. is. 


All of those would be defined as PKs somewhere with a constraint that limits not only their length but also allowable characters so you don’t get something like !@#$%^&*( as a valid ssn of length 9.  A domain is probably even better though has implementation trade-offs.

A length constraint by itself is insufficient in those examples, which are still arbitrary though the decision is outside the control of the modeler.  If the supplied values are external, which they likely are, the system under design should probably just define the values loosely and accept whatever the source system provides as-is.

David J.

В списке pgsql-admin по дате отправления:

Предыдущее
От: Rui DeSousa
Дата:
Сообщение: Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)
Следующее
От: Rui DeSousa
Дата:
Сообщение: Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)