database - Heuristic to find a primary key in a text file -


i looking library find primary key text file. imagine have csv file , dont know column(s) primary key. there library helps me (using kind of heuristic)?

i believe not knowing which, if any, field in file primary key not programming problem business problem. send business answer. reasons below.

first expected primary key , isn't in particular version of file shows problem file , should not processed. example in job, need process sales rosters come csvs. in them sales sales territory should unique. business rule. rosters not unique , fail import because 2 poeple cannot assigned same territory @ same time. problem 1 person left , took place, have no way of knowing of 2 records correct one. hence import fails. checking file contained type of information programmically have failed find pk becasue wasn't unique inteh file when should have been.

next checking existance of unique data in column when file first processed not guarantee data remain unique on time or meaningful pk.

for instance, zip code might unique today, 3 weeks might not new added mix.

nor zip code candidate pk unless file zip codes.

part number case might appear unique not on csv file because parts differnt manufacturers can have same part number, uniqueness comes combination of partnumber , manufacturer. again business rule becausee manufacturers might use same part number different versions of same thing ones of differnt colors , others might have buisiness rule unique. without knowing data meaning particular people providing files , using data, have no idea whther should pk or not.

determination of pk more uniqueness of data, meaning of the data. yes can identify possible pks (and in first case described above, might wrong using automated tool) check should not choose 1 automatically without addressing meaning of data.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -