dbTalk Databases Forums  

Designing Default Value

comp.databases.theory comp.databases.theory


Discuss Designing Default Value in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Fuchs
 
Posts: n/a

Default Designing Default Value - 10-20-2003 , 12:56 PM






Having a list of values in one table, what would be the clean way to go
to *design* a default value? (in an ER diagram)

I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application.

example table:

----------
Quote:
Currency| now i would like to have USD
--------| as the default value,
EUR | the application should then be
USD | able to preselect this value
CHF | to make usage easier;
CAD |
----------

Thank you very much everybody, your help is enormously appreciated!

Michael



Reply With Quote
  #2  
Old   
Alan
 
Posts: n/a

Default Re: Designing Default Value - 10-20-2003 , 03:08 PM






Values do not belong in an ERD. They belong in the data dictionary document
that is submitted with the rest of your assignment. What you are talking
about *is* an implementation detail, not a design detail. Depending on the
tool you are using, you may be able to build the list and select the default
automatically, but they still don't belong on the ERD.

An ERD shows abstract business relationships among the data- not
implementaion level items.


"Michael Fuchs" <fuze (AT) REMOVE (DOT) THIS.STUFFgmx.net> wrote

Quote:
Having a list of values in one table, what would be the clean way to go
to *design* a default value? (in an ER diagram)

I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application.

example table:

----------
|Currency| now i would like to have USD
|--------| as the default value,
| EUR | the application should then be
| USD | able to preselect this value
| CHF | to make usage easier;
| CAD |
----------

Thank you very much everybody, your help is enormously appreciated!

Michael




Reply With Quote
  #3  
Old   
--CELKO--
 
Posts: n/a

Default Re: Designing Default Value - 10-20-2003 , 06:16 PM



Quote:
I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application. <<

I'll take a guess at this:

CREATE TABLE Foobar
(...
currency_code CHAR(3) NOT NULL
REFERENCES Currencies(currency_code),
...);

CREATE TABLE Currencies
(currency_code CHAR(3) NOT NULL PRIMARY KEY,
priority_nbr INTEGER NOT CHECK (priority_nbr IN (1,0),
-- the following is SQL-92, but not in all products yet
CHECK ((SELECT SUM (priority_nbr) FROM Currencies) = 1),
...);

Then use a scalar subquery to find the #1 code when a NULL is given
instead of an explicit currency code to the input procedure:

INSERT INTO Foobar
VALUES (..., COALESCE (:explicit_curency_code,
(SELECT curency_code FROM Currencies WHERE
priority_nbr = 1)), ...);


Reply With Quote
  #4  
Old   
Michael Fuchs
 
Posts: n/a

Default Re: Designing Default Value - 10-21-2003 , 08:22 AM



Thanks a lot for your answer, but to be honest I do not quite
understand. I thought there is a way to somhow define a default value in
a db table. (like you can design hierarchies with unary relationships;
that was one possibility I was thinking of: to 'define' the topmost as
the default value)

Are you proposing to store this information outside the db in lets say a
plain text file and giving up basic integrity constraints?

The point is that I need to store this information on defaults in my db
(MS SQL Server 2k btw.).

Thanks a lot once again,

Michael


Alan wrote:

Quote:
Values do not belong in an ERD. They belong in the data dictionary document
that is submitted with the rest of your assignment. What you are talking
about *is* an implementation detail, not a design detail. Depending on the
tool you are using, you may be able to build the list and select the default
automatically, but they still don't belong on the ERD.

An ERD shows abstract business relationships among the data- not
implementaion level items.


"Michael Fuchs" <fuze (AT) REMOVE (DOT) THIS.STUFFgmx.net> wrote in message
news:bn17k5$mjl$1 (AT) bird (DOT) wu-wien.ac.at...

Having a list of values in one table, what would be the clean way to go
to *design* a default value? (in an ER diagram)

I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application.

example table:

----------
|Currency| now i would like to have USD
|--------| as the default value,
| EUR | the application should then be
| USD | able to preselect this value
| CHF | to make usage easier;
| CAD |
----------

Thank you very much everybody, your help is enormously appreciated!

Michael






Reply With Quote
  #5  
Old   
Alan
 
Posts: n/a

Default Re: Designing Default Value - 10-24-2003 , 09:16 AM



Your original question was about ERDs.


"Michael Fuchs" <fuze (AT) REMOVE (DOT) THIS.STUFFgmx.net> wrote

Quote:
Thanks a lot for your answer, but to be honest I do not quite
understand. I thought there is a way to somhow define a default value in
a db table. (like you can design hierarchies with unary relationships;
that was one possibility I was thinking of: to 'define' the topmost as
the default value)

Are you proposing to store this information outside the db in lets say a
plain text file and giving up basic integrity constraints?

The point is that I need to store this information on defaults in my db
(MS SQL Server 2k btw.).

Thanks a lot once again,

Michael


Alan wrote:

Values do not belong in an ERD. They belong in the data dictionary
document
that is submitted with the rest of your assignment. What you are talking
about *is* an implementation detail, not a design detail. Depending on
the
tool you are using, you may be able to build the list and select the
default
automatically, but they still don't belong on the ERD.

An ERD shows abstract business relationships among the data- not
implementaion level items.


"Michael Fuchs" <fuze (AT) REMOVE (DOT) THIS.STUFFgmx.net> wrote in message
news:bn17k5$mjl$1 (AT) bird (DOT) wu-wien.ac.at...

Having a list of values in one table, what would be the clean way to go
to *design* a default value? (in an ER diagram)

I do NOT want to know about setting default values for CREATE TABLE
statements when adding data, the question is how to design this
information so that it can be read into my application.

example table:

----------
|Currency| now i would like to have USD
|--------| as the default value,
| EUR | the application should then be
| USD | able to preselect this value
| CHF | to make usage easier;
| CAD |
----------

Thank you very much everybody, your help is enormously appreciated!

Michael








Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.