Foreign keys with values of zero rather than null

Поиск
Список
Период
Сортировка
От Campbell, Lance
Тема Foreign keys with values of zero rather than null
Дата
Msg-id B10E6810AC2A2F4EA7550D072CDE876004B2DF83@SAB-FENWICK.sab.uiuc.edu
обсуждение исходный текст
Ответы Re: Foreign keys with values of zero rather than null  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Список pgsql-admin

I map data from rows in tables to objects in Java. When I map integers in the database I map them to integer primitives in Java.  The challenge I am running into is what do I do when a table has a integer foreign key that is null.  Ideally when a table in PostgreSql has a foreign key that does not exist I would like the value to be zero rather than null.  This works really well for me because I NEVER use a key with the value of 0.

 

Is there some way for me to tell PostgreSql that a zero is the same as null when using foreign keys that map to integers?  That way I can still use cascade delete.  The only way for me to get around this issue is to remove the foreign key constraint for cascade delete.

 

Any help would be appreciated.

 

Thanks,

 

Lance Campbell

Software Architect/DBA/Project Manager

Web Services at Public Affairs

217-333-0382

 

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

Предыдущее
От: Francesc
Дата:
Сообщение: Fwd: Problems to connect to a postgreSQL 8.4 database on windows 2003 server
Следующее
От: Lewis Kapell
Дата:
Сообщение: Backslashes in bytea values