IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

why a DB2 table is built without a key?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sant532

New User


Joined: 02 Jun 2008
Posts: 48
Location: India

PostPosted: Wed Apr 14, 2010 2:20 pm
Reply with quote

can anybody give me the reason why a table is defined without a key
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Apr 14, 2010 3:21 pm
Reply with quote

part of the composite key is nullable (you would still have a unique index)
Back to top
View user's profile Send private message
sant532

New User


Joined: 02 Jun 2008
Posts: 48
Location: India

PostPosted: Wed Apr 14, 2010 4:37 pm
Reply with quote

can you give me some more information
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 14, 2010 7:27 pm
Reply with quote

Hello,

Suggest you show the create for the table/indexes you are confused about.

Someone then may have a more specific reply.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Apr 14, 2010 10:14 pm
Reply with quote

Sant532,

Quote:
can anybody give me the reason why a table is defined without a key

Reason Number 1 : it must be a de-normalized table
Reason Number 2 : During designing season they would have decided "we should forget about normalization!".

When you talk about normalization, you will be automatically talking about keys also.

Sushanth
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Apr 15, 2010 1:42 pm
Reply with quote

if you have a natural/business key , but some columns are nullable.
F.e.:
Suppose you have a parameter table with defaults on different levels.
like this table : where you keep runstats-profiles :
Code:
Db       TS     PART    Runstats_profile

NULL    NULL     NULL    "table(all) index(all) "
data1   NULL     NULL    "TABLE(all) index(all) keycard"
data1   TS1      NULL    "TABLE(all) index(all) SAMPLE 25"
data1   TS2       1      "TABLE(all) index(all) SAMPLE 10"

The unique key is DB,TS,PART

DB2 does not allow to define a Primary key on Nullable columns.
So to keep codd happy you could define a system generated key, but it is useless in the application.

so you might as well define the table without PK.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Apr 15, 2010 9:35 pm
Reply with quote

As an extra comment on my previous post :
to keep Codd really happy, we should have defined 4 tables :
- System_defaults
- Database_defaults
- Tablespace_defaults
- tablepart_defaults
Back to top
View user's profile Send private message
pardhasaradhireddy

New User


Joined: 20 May 2008
Posts: 8
Location: Hyderabad

PostPosted: Wed Apr 28, 2010 5:30 pm
Reply with quote

thank you very much Guyc for your information
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top