4

I am creating a database and in the tables the primary key value is 1 2 3 4 etc. My teacher said i can use number(4) for the primary key data type.

However some suggest that I use 'int(20) unsigned'

I am quite confused, what should i use...

Database is Oracle

Charles
  • 50,943
  • 13
  • 104
  • 142
David Garcia
  • 3,056
  • 18
  • 55
  • 90
  • what kind of database are you using MySQL, SQLServer ? – Lyuben Todorov Mar 14 '12 at 21:28
  • it depends on the size of ur data.. – Teja Mar 14 '12 at 21:28
  • 1
    Hiya, read this : http://stackoverflow.com/questions/337503/whats-the-best-practice-for-primary-keys-in-tables and then think and decide - why not declaring your id column as identity or why would you go for number and how many records your table will store etc... hope this helps, cheers! – Tats_innit Mar 14 '12 at 21:30
  • 1
    If you are using MySQL - which seems to be indicated by the `int(20)` example, then note that the `(20)` does **not** define a length restriction. `number(4)` however - which indicates an Oracle database - *does* impose an upper limit of 9999 which seems rather small for a primary key column –  Mar 14 '12 at 21:34
  • Thanks horse, i then shall use number as data type with no restriction. is this recommendable'? how about numeric??? – David Garcia Mar 14 '12 at 21:37
  • 1
    @JoseDavidGarciaLlanos: Use `NUMBER` without any restrictions (I think that is going to be translated to `NUMBER(22)` anyway) –  Mar 14 '12 at 22:43
  • Oracle does not have an INT type. – eaolson Mar 15 '12 at 00:46

1 Answers1

3

There is no single right or wrong type for key attributes. Choose a data type that accurately represents the business domain and fulfils the requirements of whoever or whatever needs to use the key.

nvogel
  • 24,981
  • 1
  • 44
  • 82