Constraints question

Dan Ridinger dlr at futurechalk.com
Fri May 13 23:49:21 UTC 2022


Hello Das,

As with code management the same principles apply to DB scripts. Allscipts should be built and applied to the database as the changes go from state to state. Now to answer your question, I prefer to have all constraints named as you have mentioned. Checking is done by the database and you just apply the normal SQL commands for the work to be done. The FK_… is the internal name applied to the constraint and is used for adding, dropping or altering a constraint.

Hope that helps.

Dan Ridinger

Sent from my iPad

> On May 13, 2022, at 11:41 AM, Das Goravani <goravanis at gmail.com> wrote:
> 
> 
> Hello,
> 
> When creating a table in Postgres, I’ve seen constraints placed in line with the rest of the columns definition, like putting the words PRIMARY KEY right next to the column name and type.. it’s just another descriptive word that gets put in line..
> 
> Then I’ve seen it done where the columns are declared, THEN they have the CONSTRAINTS listed separately with their own names, for example:
> 
> CONSTRAINT PK_AirplaneId PRIMARY KEY (AirplaneId)
> 
> They have assigned the name PK_AirplaneId to the Constraint itself.
> 
> My questions are:
> 
> Is one way better than the other?
> One gives a name to the constraint, what is that used for?
> If you do the 2nd method, is the Primary key AirplaneID or PK_AirplaneId
> 
> And they do it with foreign keys as well.. I haven’t seen one of those "In Line" but I have seen them done the 2nd way, as here:
> 
> CONSTRAINT FK_AirplaneId FOREIGN KEY (AirplaneId) REFERENCES Airplane(AirplaneId)
> 
> Done this 2nd way, is FK_… your foreign key column that you use in code or do you use the regular field, in this case AirplaneID?
> 
> On another note, in Postgres, can Primary Key columns be Type: Number 0 dp or is it only working right if you use INTEGER 32 or 64?
> 
> Similarly, for the PK column in your Omnis schema, the NULLS setting, can it be set to FALSE for No Nulls?  Or does it have to be true?
> 
> Thank you all,
> 
> Das
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 


More information about the omnisdev-en mailing list