Database design: Storing app defaults

Поиск
Список
Период
Сортировка
От David
Тема Database design: Storing app defaults
Дата
Msg-id 18c1e6480806180503l3e42747bx3e33dcffad8fb7b1@mail.gmail.com
обсуждение исходный текст
Ответы Re: Database design: Storing app defaults  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Re: Database design: Storing app defaults  (Sam Mason <sam@samason.me.uk>)
Re: Database design: Storing app defaults  ("Jonathan Bond-Caron" <jbondc@gmail.com>)
Re: Database design: Storing app defaults  (Shane Ambler <pgsql@Sheeky.Biz>)
Список pgsql-general
Hi list.

If you have a table like this:

table1
 - id
 - field1
 - field2
 - field3

table2
 - id
 - table1_id
 - field1
 - field2
 - field3

table1 & table2 are setup as 1-to-many.

If I want to start providing user-customizable defaults to the
database (ie, we don't want apps to update database schema), is it ok
database design to add a table2 record, with a NULL table1_id field?

In other words, if table1 has no matching table2 record, then the app
will use the table2 record with a NULL table1_id field to get
defaults.

This looks messy however. Is there a better way to do it?

A few other ways I can think of:

1) Have an extra table1 record (with string fields containing
'DEFAULT'), against which the extra table2 record is linked.

2) Have a new table, just for defaults, like this:

table2_defaults
 - field1
 - field2
 - field3

Which is the cleanest way? Is there another method I should use instead?

David.

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

Предыдущее
От: David
Дата:
Сообщение: Re: Database design questions
Следующее
От: David
Дата:
Сообщение: Database design: Backwards-compatible field addition