Question about Primary Key

HI
I'm going to build a Database to automate center in my university
The Database version is Oracle 10g v2
Which data type of primary key should I user?
I used number in past but I heard there is more efficient data type for this purpose
Thanks

BINARY_FLOAT and BINARY_DOUBLE are designed to store floating point numbers. If you are generating synthetic primary keys using a sequence, you are generating integers. It makes no sense from a data modeling perspective to store integer data in floating point fields. And it is exceptionally dangerous if a value gets rounded unexpectedly (floating point numbers lose precision for the trailing bits)
You'll have to clarify for me what "more helpful for indexing" means. As far as storage space goes, there may be some space savings using a BINARY_FLOAT or BINARY_DOUBLE if you have very large primary key values, but there will be a space penalty for most "normal" sequence-generated values, i.e.
SQL> create table x (
  2    col1 number,
  3    col2 binary_float,
  4    col3 binary_double
  5  );
Table created.
SQL> insert into x values( 1, 2, 3 );
1 row created.
SQL> select length(col1), length(col2), length(col3) from x;
LENGTH(COL1) LENGTH(COL2) LENGTH(COL3)
           1            8            8
SQL> insert into x values (1e20, 1e20, 1e20 );
1 row created.
SQL> select length(col1), length(col2), length(col3) from x;
LENGTH(COL1) LENGTH(COL2) LENGTH(COL3)
           1            8            8
          21           15            8
SQL> select * from x;
      COL1       COL2       COL3
         1   2.0E+000   3.0E+000
1.0000E+20   1.0E+020   1.0E+020So it takes 8 times the storage to store a 1 in a BINARY_FLOAT or BINARY_DOUBLE than it does to store that in a NUMBER column. But it takes less space if you're storing values like 1e20 (a 1 with 20 0's). If you're storing values large enough to get the space benefit, however, you're going to have rounding issues that will cause the application not to function as you'd expect which is presumably a much greater problem than a bit of wasted disk space.
Justin

Similar Messages

  • Some basic questions about foriegn key , and relationships.

    Hi
    Thank you for reading my post
    I read some documents about foreugn key and tables relation ships.
    but i still can not understnad some stuff.
    1-when we have a foreign key , we have two tables that we want to relate them together
    in a way that one of ? table columns forced to be a value from ?? table column.
    what is name of those two tables , i saw , child-parent , ..... which confuse me.
    can some one please tell me correct name of those two tables ?
    2-some times we need some kind of master details relation like :
    one-to-many : i this case MANY table will have a column to point a record in ONE table , can this relation be a foreign key relation ?
    3-we can achieve many-to-many relation only by using a helper table to host both tables primary keys in a record to relate them together.
    can you point me to some resources that help me to find answers to this questions ?
    or explain them to me ?
    thank you for your time.

    These are critical database basics that you need to understand. I would seriously recommend getting some study in, because proper relational database design relies on the basic principle of data and relationships and a process called normalization.
    In reality, you only really need one gigantic table to host data. It would include everything you would want to know about something - let's take a sales order for example. You would have to record the customer's name, address, etc. along with every item they ordered, etc. You would have a HUGE table full of data that appeared over and over and over again. This is bad design for two basic reasons: it is difficult to query, and it is very easy to have minor mistakes like capitalization or alternate spellings that prevent things from matching up properly. For example, let's say Bob orders 40 widgets and 40 digits. In our hypothetical table, we could put it in as Bob - 40 widgets and Robert - 40 digits. See how confusing this can get even in a simple example? And let's say you wanted to correct all of Robert's orders to say Bob and you found out there were 40 orders from "Robert" How would you know which ones to change?
    The process of normalization helps to reduce the chance for these types of errors in addition to creating a good basis for indexes. You normalize the data by creating sets of parent/child tables with a "key" value to match them. In our hypothetical situation, you could create a table for orders and a table for customers. In the customers table you give all the detail for the customer in one place, and you assign each customer a unique number or ID. In the orders table we add the customer ID (NOT the name) and we ensure that we are getting the customer we want, in addition to saving a lot of space and eliminating redundancy. In our example, the customers table is the "parent" table and the orders table is the "child" table. The child table references the unique entries in the parent table via that id. That reference is referred to as a foreign key. The foreign key in the child table points back to the original and complete record in the parent table and eliminates the redundancy of keeping all that extra data for every order. Foreign keys in child tables always refer to a primary/unique key in the parent field.
    That help?

  • A question about foreign key to multiple tables

    Hello everybody,
    I have a question about creating foreign key and I would appreciate if you could kindly give me a hand. Here are my tables:
    CREATE TABLE TEAM1(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM1 ADD CONSTRAINT PK_TEAM1 PRIMARY KEY(team_id);
    CREATE TABLE TEAM2(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM2 ADD CONSTRAINT PK_TEAM2 PRIMARY KEY(team_id);although the structure of both the tables is exactly the same, the values (in particular team_id) in both tables are different.
    Also I have another table named AGENT
    CREATE TABLE AGENT(agent_id VARCHAR2(20), team_id VARCHAR2(20));
    ALTER TABLE AGENT ADD CONSTRAINT PK_AGENT PRIMARY KEY(agent_id)Now the problem is that the column team_id in AGENT table is actually a foreign key, but the value can be in either TEAM1 or TEAM2. As far as I know a foreign key points only to one table.
    How can I deal with this problem? Whenever there is an INSERT or UPDATE I have to make sure that the value of the column "team_id" in the table "AGENT" is a valid value either in "TEAM1" or "TEAM2"
    Thanks in advance,
    Kind Regards,
    Dariyoosh

    Do you have the ability to change the data model? If so a more appropriate structure may be something like this:
    CREATE TABLE TEAM(team_id VARCHAR2(20), team_name VARCHAR2(20));
    ALTER TABLE TEAM ADD CONSTRAINT PK_TEAM PRIMARY KEY(team_id);
    ALTER TABLE TEAM ADD CONSTRAINT UK_TEAM UNIQUE (team_name);
    CREATE TABLE TEAM_PROJECT(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM ADD CONSTRAINT PK_TEAM_PROJECT PRIMARY KEY(team_id, project_id);
    ALTER TABLE AGENT ADD CONSTRAINT FK_TEAM_PROJECT1 FOREIGN KEY (team_id) REFERENCES TEAM(team_id);
    CREATE TABLE AGENT(agent_id VARCHAR2(20), team_id VARCHAR2(20));
    ALTER TABLE AGENT ADD CONSTRAINT PK_AGENT PRIMARY KEY(agent_id);
    ALTER TABLE AGENT ADD CONSTRAINT FK_TEAM FOREIGN KEY (team_id) REFERENCES TEAM(team_id);Edited by: Centinul on Jun 25, 2010 10:50 AM

  • Basic doubt about Primary Key/Foreign Key in Oracle Tables

    Hi,
    I have a doubt whether Primary Keys/Foreign Keys are allowed in Oracle. Some of the people I know are telling me that Oracle does not encourage having Primary Keys/Foreign keys in its database tables.
    However if I go to the ETRM and look for information about some of the Oracle Tables, I am informed that Primary Keys do exist. However I am being told that ETRM is not a reliable way of having correct information about table structure.
    It would be great if any one of you provides me with some insight in this. Any pointers to a document would be great.
    Thanks

    It is not that PK/FKs are disallowed in Oracle Apps (there are some on the standard Oracle Apps tables), but they are typically not used. I am not positive what the logic behind this is, but my guess is that it was party due to the earlier versions of Oracle Apps pre-dating declarative database referential integrity in Oracle DB and also on performance issues with the standard referential integrity with the earlier versions of declarative database referential integrity.
    As far as eTRM is concerned - I understood that the data is based on a design repository rather than a physical Oracle Apps DB. So all of the information in there is logically correct, but not necessarily enforced via the standard Oracle DB declarative referential integrity (rather by the application code or APIs).

  • Basic doubt about Primary Keys/Foreign Keys in Oracle Tables

    Hi,
    I have a doubt whether Primary Keys/Foreign Keys are allowed in Oracle or not. I have been informed that Oracle does not encourage having Primary Keys/Foreign keys in its database tables. Instead it urges users to have unique constraints on the requisite columns.
    However if I go to the ETRM and look for information about some of the Oracle Tables, I am informed that Primary Keys do exist. At the same time, I am being told that ETRM is not a reliable way of having correct information about table structure (at least the Primary Key information).
    It would be nice if any one of you provides me with some insight in this. Any pointers to a document would be welcome.
    Thanks

    FYI,
    There is seprate forum for Core Sql quieries
    PL/SQL
    Thanks

  • Question about reconciliation key

    Hello,
    I've got a reconciliation question that I feel is pretty simple, but I can't find the answer. How can an entry fetched from target recon be associated with a user in OIM? I initially though that it was the value of the "key" fields in the reconciliation filed mapping that was compared with the value of the users in OIM, but upon closer inspection, that doesn't make any sens. For instance, the AD reconciliation field mapping only has the "objectGUID" as a key. Since OIM users don't have objectGUIDs, how can an AD account be matched with a OIM user?
    This seems really basic, but I just can't find an answer...
    Thanks,
    --jtellier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    You need to look at the reconciliation rules and reconciliation Action rules . For eg , is the recon rule is User Login equals samAccountName , then upon target reconciliation , OIM recon engine will search in OIM for a matching user with user login same as samAccountName and if a match is found , a AD resource will be provisioned to the user with ObjectGUID as the primary key .
    http://docs.oracle.com/cd/E11223_01/doc.910/e11217/cnnctrcmpnts.htm#autoId9
    http://docs.oracle.com/cd/E11223_01/doc.910/e11217/processes.htm
    Hope this helps .
    Thanks
    Suren

  • About Primary key

    We declare primary key in our table..but why do we use Constraint with primary key? and what is the meaning of constraint in oracle

    Hi,
    Constraints is some kind of rule and those rule have different category, which is define as Key.
    Like.
    If you r define Primary key that time rule would be different and for other like unique, not null rule would be different.
    So we can characterize the constraint with different role and definition.
    Regs,
    Brij

  • Concept about Primary Key index

    I have a partitioned table as follow:
    CREATE TABLE TEST
    (TEST_KEY NUMBER(10,0) NOT NULL
    ,FOREIGN_KEY NUMBER(10,0) NOT NULL
    ,PARAM_ID NUMBER(10,0)
    ,PARAM_VALUE VARCHAR2(256)
    PARTITION BY HASH (operation_key) PARTITIONS 15
    STORE IN (TEST_R1_TS, TEST_R2_TS, TEST_R3_TS, TEST_R4_TS, TEST_R5_TS)
    CACHE
    I also created a partitioned index for the TEST_KEY to be used as primary key index.
    CREATE INDEX TEST_PK_IDX ON PARAMETER_1(TEST_KEY) LOCAL
    STORE IN (TEST_i1_ts, TEST_i2_ts, TEST_i3_ts, TEST_i4_ts, TEST_i5_ts);
    When I try to run alter table to add primary key, I got index not exist error?
    SQL> alter table TEST add (constraint test_pk primary key (test_key) using index test_pk_idx);
    alter table parameter_1 add (constraint pa1_pk primary key (parameter_key) using index pa_pk_idx)
    ERROR at line 1:
    ORA-01418: specified index does not exist
    BUT, I could find my index in the USER_INDEXES table...
    SQL> select index_name from user_indexes where index_name like '%TEST_PK%';
    INDEX_NAME
    TEST_PK_IDX
    Why? Help is very appreciated.
    Thank you in advanced.

    check the names of the tables in the script you give ... they are different for the table and the index. When you add the constraint the table name and column name mysteriously change in the error message, so I think that you aren't showing us what actually happened.

  • Question about the key of loops

    I am reading the logic getting started book
    and they say there are two type of loops
    audio files and software instruments.
    in the book it says:
    "the advantage of apple loop audio files is their ability to automatically match the tempo and key of a logic project"
    is that possible an audio file being able to change key to the key of your project?? how about if the audio loop is a guitar strum strumming a C chord, it is able to switch the strum to a D chord, F chord, etc...?? how does that work??
    sorry if this is a stupid question
    I can understand how the software instrument loops would be able to change to match your project because they are midi and the midi notes can just be transposed to whatever Key, chord, etc....
    please explain if you know i will really appreciate it
    Thanks

    wow that is crazy i can't believe it is able to transpose audio loops (not midi) to different keys. especially stuff with more then one note playing at the same time like guitar strum.
    I know how to set up the key in logic and change it etc... i was really wondering how it is capable of doing this?? does it have some kind of melodyne or autotune built in to it?? i never heard of software being able to do this with pre recorded audio that plays more than one note at a time.
    Message was edited by: smurffy

  • Curious question about tab key selecting?

    I'm not sure how to word this query so try to bare with me.
    I sometimes use the tab key to select the next file or folder instead of the arrow keys, but I've noticed that when I have a series of folders and/or files that are in numerical order, the tab key doesn't select the files and folders in the order that they are listed it selects them in a order that is similar to alphabetical order.
    Such as this:
    This is an example of the file names and the numerical order they're listed in:
    9
    28
    29
    30
    40
    300
    2006
    2025
    A
    This is the order the tab selects the same files:
    2006
    2025
    28
    29
    30
    300
    40
    9
    A
    If the 9 file is selected then I hit tab key to select the next file, the next files selected is A it will skip over the other files. The arrow Keys don't do this.
    My question is why is this the case?
    Not really a big deal but I was curious why it does that.

    You are correct for the use you've described - using tab in list view, also in icon view. The tab key moves in alpha-numeric sequence but the numeric is by 1st numeral, 2nd numeral, etc if two or more have the same first numeral not by total number size.
    The arrow keys are essentially directional. In icon view you use L/R to move to the next item and up/down to move vertically.
    This is the standard use but individual applications use these keys differently. In a table/database it's common for the tab to move from cell to cell and the arrow keys to move through the characters in a cell but even these can depend on the particular software package.
    This is all part of the learning curve for computer users!
    Neville

  • Question about activation key for pre-installed software after hard drive failure.

    I had a hard drive failure on my MacBook Pro last week and had it replaced by Apple.  When I restored my computer with a Time Machine backup, Office 2011 wants an activation key to start up again.  Problem is, I had Office pre-installed when I bought my MacBook by Apple.  Where do I get the activation key to get it working again?
    Thanks
    Q

    Do you still have the signons.sqlite and key3.db files from the IT setup?
    You can find the sync account password and the sync (recovery) key in the password manager on computers where a sync account with a specific e-mail address has been set up.
    Look for:
    * chrome://weave (Mozilla Services Password)
    * chrome://weave (Mozilla Services Encryption Passphrase)

  • Question about primary file

    When we create a contributor data file primary file i.e. default.xml is empty. From the contribution mode the changes which are made when saved gets reflected in XML. Any idea on which service is being called to update the default.xml file?
    Consider the following scenario ... we have a hcsp form with custom meta data fields and a text area field.
    The primary file field is hidden and am using sitestudio variables to check in default.xml file.
    When the data is entered and upon submission i am calling check in service. Is there a way to store the textArea content in the default.xml file?

    Hi ,
    Can you elaborate on what exactly is the requirement which you are looking at .
    Thanks
    Srinath

  • Question about hot key to jump between fields in oracle form

    say I have bunch of orders to upload,
    at the order number field I type in the number
    and move the mouse to click on next line to type another number
    how can I use some hot key to replace the mouse movement.
    I know if use tab key several times you can come to the next line eventually, but is there any better hot key just move to the next line?
    my purpose is to automatically upload bunch of orders, and bypass the mouse move, if there is some similar case study material, I really appreciate.
    thank you

    There is one built-in to move to the next record programatically. Like...
    NEXT_RECORD;It is a restricted procedure check the forms help.
    In your case can use on KEY-NEXT-ITEM trigger.
    or if you are uploading from any file or any other source then also you can use this built-in in your code while uploading.
    Check the below documentation. Select on your version.
    http://www.oracle.com/technology/documentation/6i_forms.html
    -Ammad
    Edited by: Ammad Ahmed on May 25, 2010 12:15 AM

  • The question about Multiple key

    Hey all:
    I'm having a problem trying to create the multiple key (just like the c++)
    In C++ , it looks like the following
    typedef pair<short,short> Bipair;
    map<Bipair,double> P_WD_MAP;
    In Java
    public class someclass{
    private class Bipair implements Comparable{
    short a,b;
    public Bipair(short a,short b){
    this.a=a;
    this.b=b;}
    public int compareTo(Object o){
    if(((Bipair)o).a==this.a&&((Bipair)o).b==this.b)
    return 0;
    else if(this.a+this.b>((Bipair)o).a+((Bipair)o).b)
    return 1;
    else
    return -1;}
    HashMap<Bipair,Double> P_WD_MAP=new HashMap<Bipair,Double>();
    It's ok to use the usage. But it needs the huge memory.
    Because it needs to create the huge instances of the class Bipair.
    Besides to use the symbol to connect the multiple key
    ( String.valueof(a)+"_"+String.valueof(b) ==> key )
    Does it have the more effective method to create it ?
    Thanks a lot.

    You mean if Bipair must implement the Comparable
    interface in this case?
    Not really, but you can as well keep it just in case
    you use the Bipair objects in a situation where you
    want them in sorted order.I get it.
    Because I don't implement the equal function.
    So it creates the duplicate objects. (So it need the huge memory ^^|| )
    The compareTo function only provides the orderly object, and don't provide
    to avoid the duplicate object.
    By the same way , if I use the TreeMap to contain it.
    It's ok , too . (implement compareTo,equal,hashcode )
    Thanks a lot . ^_____________________^

  • Question about generate key press event to system. help plz.

    I am wondering if it is possible to write a java program to generate key press event(not receiving)to the local system so all the other program in the system receive those key press event also. Thanks.

    Hi,
    :. I don't know what exactly you intend to accomplish. But, I have used the following code in order to simulate keys pressing inside a Java application.
          /* - - - Simulates TAB (java.awt.Event)
          EventQueue evtq = Toolkit.getDefaultToolkit().getSystemEventQueue();
          evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_PRESSED,
                          0, 0, KeyEvent.VK_TAB, KeyEvent.CHAR_UNDEFINED) );
          evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_RELEASED,
                          0, 0, KeyEvent.VK_TAB, KeyEvent.CHAR_UNDEFINED) );
          /* - - - Simulates Shift+TAB (java.awt.Event)
          evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_PRESSED, 0,
                          InputEvent.SHIFT_DOWN_MASK, KeyEvent.VK_TAB,
                          KeyEvent.CHAR_UNDEFINED) );
          evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_RELEASED, 0,
                          InputEvent.SHIFT_DOWN_MASK, KeyEvent.VK_TAB,
                          KeyEvent.CHAR_UNDEFINED) );:. However, as far as I know to send keys to the whole OS you have to create a 'Hook' as described inside Win32API documentation. That's for Microsoft Windows naturaly.
    Cheers.
    Roque

Maybe you are looking for