Sql Duplicate Value Primary Key

Discussion in 'Databases' started by ironmankho, Feb 9, 2013.

  1. #1
    hi
    every one i want to enter duplicate value in primary key mysql .......is there solution ?
     
    Solved! View solution.
    ironmankho, Feb 9, 2013 IP
  2. #2
    No you can't enter the duplicate value in primary key.
     
    icecube media, Feb 11, 2013 IP
  3. TestingWhiz1

    TestingWhiz1 Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Primary key is a unique key id in any relation.And there would be one and only one primary key in a relation.
     
    TestingWhiz1, Feb 15, 2013 IP
  4. worldart

    worldart Banned

    Messages:
    26
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    28
    #4
    If you want to enter duplicate value then you cannot set it as primary key, primary key is a unique key so either you should have it unique or dont declare it as a primary key
     
    worldart, Feb 19, 2013 IP
  5. kulik

    kulik Member

    Messages:
    162
    Likes Received:
    18
    Best Answers:
    1
    Trophy Points:
    45
    #5
    The whole purpose of the primary key is not to have duplicates and can't. You should be more specific in what you want to do. Why would you ever want multiple ID's of the same value?
     
    kulik, Feb 19, 2013 IP
  6. traxport121

    traxport121 Active Member

    Messages:
    1,201
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    63
    #6
    If you want to add duplicate value in it, remove it as a primary key first. Go to the design view of your DMBS and delete the PK.
     
    traxport121, Mar 2, 2013 IP
  7. jiah

    jiah Greenhorn

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    Noone enter a dublicate value in primary key in sql
     
    jiah, Mar 15, 2013 IP
  8. Chris Barnhart

    Chris Barnhart Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    I will elaborate on the original question as I have the same which has not been answered.

    I want to have a 'primary key' field in my SQL database that may have duplicates. The reason I want it to be a primary key is that I believe doing so will allow me to rapidly access the relevant set of records from a large database in a real-time (as fast as possible, AFAP) data retrieval application.

    My database columns with data are:
    time data_id data
    1000.1 7 xxx
    1000.2 7 xxx
    1000.3 7 xxx
    1000.3 9 xxx
    1000.4 7 xxx

    These data records arise from a science experiment that products many data samples (records) per second. The resulting database will be upto 20GB with 20 million records. The combination of time and data_id will always be unique. Time is always increasing, but there may be several data samples at the same time but ith different data_id.

    Reviewing the data will be done by plotting it in an real-time interactive manner. My display application will request samples between two times and display the data points. The request for the time range comes by sliding a scroll bars on the plot, all this needs to happen very rapidly (eg 0.1 seconds or less)

    Possibility given that the data always enters the data base in the order I want to retrieve it, nothing special is required to speed it up? Or possibly there is a lesser indexing specification that allows duplicates? Or possibly I combine time and data_id, make it a primary key, and search using only a portion of the key?

    eg:
    time_data_id:
    1000.1_7
    1000.2_7
    1000.3_7
    1000.3_9
    1000.4_7

    Thank you.
    Chris
     
    Chris Barnhart, Mar 19, 2015 IP
  9. SalvadorWilliam

    SalvadorWilliam Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    Yes, it is possible to do. For this you just need to disable the constraints. Then you can enter any desired value.
     
    SalvadorWilliam, Jul 24, 2015 IP