|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Mon Mar 22, 2004 11:50 am
Duplicate Entries in Databases |
I am trying to create a database of characters and in order to do this I copy lists of the people online at different times into a text file and import that into the database ... Is there a way I can make the database remove duplicate name entries ?[B)]
|
|
|
|
Ryntrax Wanderer
Joined: 15 Mar 2004 Posts: 55 Location: USA
|
Posted: Tue Mar 23, 2004 10:03 pm |
Now a better approach to writing this would be to make a trigger for the player online. THe make the value of the trigger a while statement and if the player name is already in the DB then just dont add it. If it isnt add it to the end. WOuld need an exajmple of the output to help further.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Mar 23, 2004 11:41 pm |
If the names are all you are recording, you don't need a database. This can be done with a list-variable. If you use #ADDITEM to add the names, no duplicates will be added. If you ever do get any duplicates (through other methods of adding to the variable), they can be removed using the %dups function.
If you are recording names and ONE other item (such as guild), you still don't need a database. This can be done with a record-variable. Use #ADDKEY to add the name as the key, and the associated item as the value. Record-variables don't allow duplicate keys, so with the name as the key you won't get duplicates.
If you are recording more than two items per character, you will usually need a database. The only way to prevent the database from making duplicate entries is to check the database to see if an entry for that name already exists before adding a new record. Likewise, to remove duplicates, you (or a script) will have to check each name in the database to see if it has more than one record and delete the extras.
It doesn't really matter whether you do this online or offline. Either way, you (or a script) will have to check the database for existing records before each name is added or else check each name later in order to remove whatever duplicates you created. |
|
|
|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Thu Mar 25, 2004 4:41 pm |
Ah well .. I was hoping that there was some databaase function to automatically remove duplicates of a particular field. This is definitiely a database job by the way as basically i'm building a large database of all the players in my mud along with their race and gender(i use a script to collect the race and gender info for the database).. or as close to 'all' as I can get anyway .. I found a feature in my text editor that can remove duplicates so i'll do it that way and import the list (1000+ entries would take forever to go through manually *grin*).
|
|
|
|
Bromax Wanderer
Joined: 03 Jan 2002 Posts: 66
|
Posted: Thu Mar 25, 2004 7:52 pm |
quote: Originally posted by LightBulb
they can be removed using the %dups function.
what he said |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Mar 25, 2004 8:01 pm |
I specifically said that applied to list variables and not databases. Please don't quote me out of context.
|
|
|
|
|
|