Re: Syntax question about returning value from an insert

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Syntax question about returning value from an insert
Дата
Msg-id 69bf1ac3-1b6c-f258-839e-bce9ee5d2abf@aklaver.com
обсуждение исходный текст
Ответ на Re: Syntax question about returning value from an insert  (stan <stanb@panix.com>)
Список pgsql-general
On 12/25/19 3:09 PM, stan wrote:
> On Wed, Dec 25, 2019 at 02:34:43PM -0800, Adrian Klaver wrote:
>> On 12/25/19 12:39 PM, stan wrote:
>>>

>>
>> Other approaches have been suggested, e.g. use a traditional FK
>> relationship. The big unknown in you present system is what:
>>
>> SELECT cost_category_key from t2 where type = 'Misc'
>>
>> will return. The implication is that it maybe more then one value(key) in
>> that case, which key would you use?
> 
> There is more that that. There is a project number, so the actuall key
> represents the combination of project number, and cost category, Thire is a
> constraint on T2 that assures that these combinations will be unique.

So you have the unique key for the parent record of a FK relationship.

> 
> When the 1st record for a project, that gets charged to the misc. cost
> category is entered, I need to assure that combination gets inserted into
> T2

When you start a new project seed it with the project number, cost 
category, type='misc' record.

> 
>> If not and  cost_category_key: type is one to one then why have both?
>> Just make one unique(or PK) and the parent for the cost_category_key in t1.
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



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

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: Syntax question about returning value from an insert
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Syntax question about returning value from an insert