unique

Make MySQL table unique

Hay, I created a spider to crawl through a PDF document and log every word in the document into a table in a MySQL database. Obviously words like 'the', 'and', 'or' etc appear in a book many, many times. I'm just wondering what's the quickest method to remove dupe values from a table? ...

What's the most pythonic way to ensure that all elements of a list are different?

I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion. This is the way I do it now: If there are two elements: try: assert(x[0] != x[1]) except: print debug_info raise Exception("throw to caller") If there are three: t...

Mysql Unique Query

I have a programme listing database with all the information needed for one programme packed into one table (I should have split programmes and episodes into their own) Now since there are multiple episodes for any given show I wish to display the main page with just the title names in ascending and chosen letter. Now I know how to do th...

Most Efficient Way to... Unique Random String

I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over. Is there a more efficient way to do this proces...

Get element by id via regex jQuery

Html element contains complex & unique id, composed from namespace as prefix and incremented index - as postfix. I try do it with wildcard expression for id. If to use simple way without namespace, that it works fine: $j("[id*=service_selected_]").click(function(){ ... In order to keep uniqueness,i need provide namespace part within...

How to enforce DB integrity with non-unique foreign keys?

I want to have a database table that keeps data with revision history (like pages on Wikipedia). I thought that a good idea would be to have two columns that identify the row: (name, version). So a sample table would look like this: TABLE PERSONS: id: int, name: varchar(30), version: int, ... // some data assigne...

XML Schema - Key in sequence

I'm trying to put a key in sequence and am being bombarded with errors. It seems I can't do this. Additionally, I am being told my key needs a field and selector, which I have been able to find very little documentation on. (In fact, in desperation, I downloaded Liquid XML Studio [vs. Notepad] and searched it's help files. . . to find NO...

Extending uniq method

This is Ruby 1.8 Question: We all know how to use Array#uniq : [1,2,3,1].uniq #=> [1,2,3] However I'm wondering if we can monkey patch it in a way to work with complex objects. The current behavior is like this: [{"three"=>"3"}, {"three"=>"4"}, {"three"=>"3"}].uniq #=> [{"three"=>"3"}, {"three"=>"4"}, {"three"=>"3"}] The requeste...

mysql 7columns pk vs. 1 column md5 unique constraint

Hi, i have a very large table which is currently approx 70M rows and growing daily by the thousands , this schema is tipping over every day now so i'm moving to a partitioned table and redesigning the ddl . the table is basicly a collection of NOT NULL INTEGERS(some medium some INT some tiny) which need to have a unique constraint for a...

std::unique analogue in Qt?

I have browsed the documentation, but didn't find one. Any ideas? ...

PHP Image uploading - uniqueness via microtime()

If I make the filename of each uploaded file PHPs microtime(), are the risks of a collision realistic? And is there a way to further randomize the filenames? I'm expecting about 20,000 uploads in about a week. That's 2800/day or 119/hour (assuming even distribution). Does anyone have any experience with assuming microtime to be unique? ...

How to make "No Duplicates" column in Sql Server 2008 ?

I have simple table in my SQL Server Database. This table contain two columns: ID int, Name nvarchar(50). The ID column is the primary key for my table. I want the "Name" column to be "(No Duplicates)", like in Microsoft Access, but this column isn't the primary column. How could I do this? ...

n-values UUID generator, reusable IDs

I need a simple UUID generator. The ID is required to be unique for this single instance. Another requirement is, that it has n hashes coexisting at a time, and being releasable. I don't know wether this fits the UUID concept or not. I allrdy thought about a Stack with n-values using pop and push, but this practice seems bad memory wise....

filtering lists in python

hello, I want to filter repeated elements in my list for instance foo = ['a','b','c','a','b','d','a','d'] I am only interested with: ['a','b','c','d'] What would be the efficient way to do achieve this ? Cheers ...

PHP short unique ID generation using auto_increment?

I would like to generate a short, unique ID without having to check for collisions. I currently do something like this, but the ID I currently generate is random and checking for collisions in a loop is annoying and will get expensive if the number of records grows significantly. Normally worrying about collisions isn't an issue, but t...

Preventing duplicate matches in RegEx

The following code string expression = "(\\{[0-9]+\\})"; RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase); Regex tokenParser = new Regex(expression, options); MatchCollection matches = tokenParser.Matches("The {0} is a {1} and the {2} is also a {1}"); will match and ca...

[Java] Find a Database table's unique constraint

Hi, I'm trying to find the unique constraints of a table using Java (on an Oracle Database, but that should make no difference). I found a way to discover the Primary Keys of a table, thanks to DatabaseMetaData's getPrimaryKeys(....); However I was unable to find the unique constaints of the tables, and the Internet was not able to he...

.NET collection that throws an exception when a duplicate is added

Is there a collection (apart from Dictionary) in the .NET framework (3.5) that throws an exception when a duplicate is added? HashSet does not throw an exception here: HashSet<string> strings = new HashSet<string>(); strings.Add("apple"); strings.Add("apple"); Whereas the Dictionary does: Dictionary<string, string> dict = new Dictio...

Data-structure that stores unique elements but answers queries for another ordering in C++

Hi, is there a data structure, which stores its elements uniquely (for a given compare-Functor) but answers queries for the highest element in that data structure with respect to another compare-Function ? For Example: I have a class with two properties : 1) the size 2) the value I'd like to have a data structure which stores all elem...

How to declare a range overlaping constraint in PosgreSQL database?

Let's say we are having a table with this definition: range ( id bigint primary key, colourId int references colour(id), smellId int references smell(id), from bigint, to bigint ) This table is actually a reduced view over enormously big table: item ( id bigint primary key, colourId int references colour(id), smellId ...