Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

why a DB2 table is built without a key?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: why a DB2 table is built without a key?
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: 1280
Location: Belgium

PostPosted: Wed Apr 14, 2010 3:21 pm    Post subject:
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    Post subject:
Reply with quote

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

Site Director


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

PostPosted: Wed Apr 14, 2010 7:27 pm    Post subject:
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: 1013
Location: India

PostPosted: Wed Apr 14, 2010 10:14 pm    Post subject:
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: 1280
Location: Belgium

PostPosted: Thu Apr 15, 2010 1:42 pm    Post subject:
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: 1280
Location: Belgium

PostPosted: Thu Apr 15, 2010 9:35 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us