Why do we use Meaningful PK or Meaningless PK ?

Hi All,
My questions below is very basic (I am a developer not a dba ..)
I see on database design that the Primary Key (PK) is usually not the "Key" that is visible to user, e.g : if we has Invoice table, the columns are :
InvoiceID (PK) => this is only visible to developer, user never see it, usually
using sequence.
InvoiceNumber => this is visible on UI, reports etc
From the design point of view, what is the reason of the above design ?
Thank you for your help,
xtanto

Guys, my opinions are as follows...
1) Psychology says that human being like the things in order. If that thing is primary key (with a sequence) of your table then, it will help you alot in one or the other way.
2) I feel very comfortable and confident when I write complex queries using surrogate keys.
3) Suppose I say I will use natural keys for parent tables. In some situations, child tables has to be implemented by surrogate keys. This will result in some tables with natural keys and others with surrogate keys. This may sometimes lead to confusion. To avoid this type of situation and to maintain consistency, people prefer to use surrogate keys in all the tables.
4) Surrogate keys help in guessing. Let us see the following rows (first column is a key)....
With surrogated keys
Key, bank_account_number, customer_name,description
456,123765,'oracle corporation','business sector'
457,409867,'rotary high school','education sector'
458,6784,'AT and T','telecommunication sector'
With Natural keys
bank_account_number, customer_name,description
123765,'oracle corporation','business sector'
409867,'rotary high school','education sector'
6784,'AT and T','telecommunication sector'
In both the cases, the first column is a primary key. With surrogate keys, I can easily say 'AT and T' got entered in the table after 'rotary high school' and 'oracle corporation'. You remember the key 458 for 'AT and T' and assume you have millions of such rows. In your development sometimes you will come across with a row with 123. Surrogate key helps you to say 'Oh this is old row than AT and T row'. May be your GM asked. "Dear DBA which customer is old, by providing a list of customers?" . I just have to follow the surrogate keys. In the second case you will not have that type of implicit guessing.
5) Assume the cases as in point 4. May be 409867 account number of 'rotary high school' of bank 'US federal bank' matches with 409867 account number of other customer say 'xyz' of bank 'Australia federal bank'. In this case, you will think to put (account number,bank name) as primary key. In some other cases you will have to have 3 or 4 columns to uniquely identify the row. I think instead of including primary key with two or more columns, why not use surrogate key with just one column. This surrogate key never cares about the data present in other collegue columns in the table.
Hope I put some light on this issue. I welcome others to help me understand the importance of surrogate keys in a more better way.
-aijaz

Similar Messages

  • Why do I use my ipod as a camera when I lose precious photos even when I try to back up before an update! Selling my ipod at the first chance I get

    Why do I use my Ipod tiuch as a camera when lose precious photos of my granddaughter every time there is an operating system update? Even when I try to back up the ipod, I can't find the pics etc on my pc. It is very annoying and I am seriously considering selling my ipod because of this. No warning is given that photos will be lost. So very disappointed in aple, lost all my music last time, as well as my pics.

    Yes, using the windows photo capture application is how you get photos taken with the iPod onto your pc. You should store them there, and organize them in folders.
    Create one main photo folder. Inside that folder create additional folders to hold photos. Each folder will become an album on an iPod, iPad, or iPhone. Do not next any other folders inside the first album folder.
    Then start iTunes on your pc and connect your iPod. Select your iPod in itunes and select the Photos tab that will be ps enter. You will most likely have first find your main photos folder. Ten select to sync all photos from your pc or select only those albums you want to have on your iPod. The click on Apply or Sync. That will copy the photos to your iPod.
    If you should do something later to cause these albums to disappear from your iPod you can quickly copy them back by doing another sync.

  • How do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full

    how do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full.. HELP!

    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.

  • Why do we use open URL in default browser function? What are the uses of it?

    Why do we use "open URL in default browser" function?  What are the uses of it?

    kdm7 wrote:
    Okay.
    So can we keep a web button to access the www.ni.com ? So that web site opens only when button pressed?
    P.S  I,m a newbie.
    Yes, you can also, e.g. include a help file or manual as html and open that in the browser.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • WHY CANT I USE FINAL CUT EXPRESS HD IN MY MACBOOK

    WHY CANT I USE FINAL CUT EXPRESS HD IN MY MACBOOK?

    hey there DavoMrMac,
    according to Apple's 'site:
    System Requirements
    Macintosh computer with 500MHz or faster PowerPC G4 or G5 (550MHz for PowerBook G4) or Intel Core Duo
    512MB RAM
    Display with 1024-by-768 (or higher) resolution
    An AGP or PCI Express graphics card compatible with Quartz Extreme or an Intel GMA integrated graphics processor in MacBook or Mac Mini
    Mac OS X 10.4.6 or later
    QuickTime 7.0.4 or later
    HDV features require 1GHz or faster processor and 1GB of RAM (2GB recommended)
    500MB disk space required for applications; additional 16GB of additional storage space for Soundtrack and LiveType content (can be installed on separate disks)
    DVD drive for software installation
    i've been running FCE HD 3.5 on my MacBook since i got it in November '06. runs okay for the few short SD projects(15:00) or less i've put together.

  • I cannot use a website I need to use, with Firefox 5.0. So, I need to uninstall and go back to 3.5 or 3.6. Please advise. Also, my control panel locks up since Windows Explorer has pbms. Which is why I am using Firefox instead. Thanks for any help!

    I cannot use a website I need to use, with Firefox 5.0. So, I need to uninstall and go back to 3.5 or 3.6. Please advise. Also, my control panel locks up since Windows Explorer has pbms. Which is why I am using Firefox instead. Thanks for any help!

    ''I figured it was going to be FAFSA causing your problem.''
    Install Portable Firefox 3.6.x to your hard drive for that one website. It won't affect your current Firefox installation at all. <br />
    http://portableapps.com/apps/internet/firefox_portable/localization#legacy36

  • Function module: why do we use FM and what is the purpose of using FM

    hi,
       Can any please explain. Why do we use FM?
                                           What is the purpose of using FM ?
                                           Where we are using FM and for what tables in R/3 ?
    I could be thankful to you if any one answer above questions.
    Arun

    Hi,
      We go for creating FM when there is a chance of using the same code in different reports in R/3.
    Suppose I have a requirement say, to display the Payer Name for every sale order.
    This is most common requirement in any project.
    You can create a FM say READ_CUSTOMER_NAME in SE37.
    Write a select statement from the table VBAP to fetch the Payer Name based on the Sales Order.
    Now you can activate the FM and it is ready to be used across all the reports in R/3.
    Need : To avoid redundant coding and to modularize the code.
    If you want to see the list of Standard FMs, got SE37 --> press F4 and you'll get all the SAP standard FMs.
    For customized FMs (User defined), type Z* or Y* and press F4.
    Hope this helps a bit !!!
    Regards,
    Balaji V

  • What is the significance of Marker interface? Why are we using, even though

    What is the significance of Marker interface? Why are we using, even though it has no method?

    Well, what's the significance of an interface? They can define a set of methods a class may implement but the class could equally well implement these methods without the interface so why having interfaces at all?
    The answer is that the most important aspect of an interface is that it constitutes a type (you can declare variables of it). And it's a type regardless of how many methods it defines, including none. So the reason for having a marker interface is that you're interested solely in the type aspect of interfaces.

  • Why do we use dunning for vendors

    Hi All...
    We create dunning for customer to send them reminders for payment....But why do we use dunning for vendors (in Vendor Master Data)??
    Txk,
    Umesh

    Hi,
    If you dun customers who are also vendors and want to clear the items, the dunning program lists both the overdue customer items and the overdue vendor items in the dunning proposal, and determines a joint balance.When you dun a customer who is also a vendor, only the master record information of the customer is relevant.The items can only be cleared if the same dunning procedure has been defined in the standard dunning area for both customer and vendor.
    Hope this helps you. let me know if you need anyother information.
    Rgds
    Manish
    ===========================================================================

  • Why do we use Allowed Operations in DML Process

    Hello,
    Why do we use Allowed Operations in DML Process ??
    Can you please clear this confusion:
    I am using apex 4.1. oracle 11g R2 SOE ...
    Using the Wizard, I created a Form and IR on Dept Table...
    In the form page:
    - Create Button
    The name is "CREATE"
    NO Database Action
    - DML Process
    Allowed Operations: nothing is checked
    This will insert a new row in the Dept table
    In the form page:
    - Create Button
    The name is "CREATE2"
    Database Action : insert
    - DML Process
    Allowed Operations: nothing is checked
    This will insert a new row in the Dept table
    So, What difference does it make if INSERT check box in Allowed Operations of DML Process is TICKED OR NOT ??
    Regards,
    Fateh

    kdm7 wrote:
    Okay.
    So can we keep a web button to access the www.ni.com ? So that web site opens only when button pressed?
    P.S  I,m a newbie.
    Yes, you can also, e.g. include a help file or manual as html and open that in the browser.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Why cannot I use hidden or display only item to store value for insert?

    hi, Gurus:
    I have a question:
    I implemented a form with report region in a page, the update works OK, but the add function has a problem:
    There is a column, offender_ID, which is a foreign key for another table, it should not be null during insert. However, even I pass the offender ID from master page when user click the create button, and it did shows in the form, it must be a text filed to insert successfully, why cannot I use hidden or display only item to store this value for insert? (If I use hidden or display only item, insert won't be successful, apex reports I tried to insert a null value to offender_ID column.)
    Many Thanks in advance.
    Sam

    Hi,
    There is a column, offender_ID, which is a foreign key for another table, it should not be null during insert. However, even I pass the offender ID from master page when user click the create button, and it did shows in the form, it must be a text filed to insert successfully, why cannot I use hidden or display only item to store this value for insert? (If I use hidden or display only item, insert won't be successful, apex reports I tried to insert a null value to offender_ID column.)I think both hidden and display items have attributes that can cause problems because of different ways these items function than non-hidden and non-display-only items function. Display Only items have a "Setting" of "Save Session State" Yes/No? That can be a problem.
    Would you do this? Make these items regular items instead and see if you can get those working. Then, we will try to change the fields back to hidden or display only.
    Howard
    Congratulations. Glad you found the solution.
    Edited by: Howard (... in Training) on Apr 11, 2013 10:26 AM

  • Why should I use Java

    HI,
    Someone asked me why are you using Java when you can use Visual Basic.
    Well, I ask this question in this forum ?? why ...
    please leave out the portablity part
    --j                                                                                                                                                                                                                                                                                                                                                   

    Well, here is my 2 cents, as it were. I tried learning VB, and found that while it is powerful, when it comes to designing specifically for Windows systems, I found it extremely hard to understand. When I first learned Java, it didn't take me long to understand the concept and relation of classes and objects, and I was writing Swing apps in no time. With VB, it wasn't that easy. Yes, it was mostly drag and drop and add a few lines of code, but I don't like that. I like to be able to get down into the code and see why it works the way it did, and with VB, I just couldn't grasp it. But with Java, it took me no time at all to be able to understand why it worked the way it did, and because of that, I will always choose Java over any other language, except maybe Miva Script, which is a server side language used for e-commerce websites. It was another language that was easy to learn. Does this mean I'm a lazy programmer, always taking the easy way out? Probably, but if it's easy for me to learn, it's easy for me to implement.
    James

  • After downloading my file the word document is mostly gibberish.  Why? service used exportPDF

    After downloading my file the word document is mostly gibberish.  Why? Service used "exportPDF".

    Hi shelbyrn,
    The quality of a conversion really depends on the quality of the original PDF file. Please see Will Adobe ExportPDF convert both text and form... | Adobe Community.  Do you know what or how the PDF file was created?
    You may have better luck by disabling OCR as described in this document: How to disable Optical Character Recognition (O... | Adobe Community. (Note, however, that is  option isn't optimal if the PDF was created from a scanned document; you'd want OCR enabled to convert the image text in the PDF to editable text).
    Best,
    Sara

  • Why i cant use facebook on my iphone 3gs

    why i cant use facebook on my iphone 3gs?

    If you want to use the Facebook app and you don't have an older version saved in your iTunes library, then you won't be able to download it on that device.  Either use Safari to access Facebook or get a device that can run iOS 7 and install Facebook.

  • Why cant i use a bought call-tone bought through I-tones for calling tones for just one of my contacts?

    Why cant i use a bought call-tone bought through I-tones for calling tones for just one of my contacts?

    What makes you believe that you can't? To set a custom ringtone (or SMS tone) for a contact, go to that contact entry, tap the Edit button in the upper right. You can then edit both ringtones and SMS tones for that contact.

Maybe you are looking for

  • Splitting midi tracks?

    I start by creating a new project and a single software track I then choose a drum kit from the media library with the Caps Lock on I hit Record and bash out some different drums on my computer keyboard. With the track and region selected I choose Mi

  • IPad 3 keeps syncing music!

    On the summary page....I have the iPad set to manually manage music & the "sync only checked songs" is greyed out.  On the music tab... "sync music" is also unchecked.  However, after I sync apps, books, etc, the music begins to automatically sync to

  • How do I stop text layer from turning black while editing text?

    Photoshop CC up to date 5 years PS experience Restart of file and PS didn't resolve the issue Creating Smart Object didn't resolve issue When attempting to add simple text on an individual layer, the layer is turning black. This prevents me from seei

  • Delete Receipt not Reverse in Oracle Receivable R12.1.3

    Hi, Is it allowed to delete receipt, which is not reverse the receipt ? and what is the effects ? Thanks

  • Powerbook to Dell 24" DVI problem

    Just got a Dell 2405FPW, which works fine outputting my Titanium 15" Powerbook via the DVI to VGA adaptor. However if I plug straight into the DVI input of the Dell with Dell's cable, my Powerbook doesn't sense any external monitors. Maybe the cable