unique

deleting a unique record from List

i have a list of employees.My employee class is as follows public class Employee{ int empid; String name; ... } now i want to remove a employee from list whose empid is 5.One way to do is to iterate the list and check if empid == 5.Is there any other way by which i can do it? Also is want my list to contain employees with uniq...

SEO strategy unique ID in URL

Hello, What would be the best way for a URL to look like if it should contain an ID and a name? /product/123/screwdriver-black /product/screwdriver-black/123 /product/123-screwdriver-black /product/screwdriver-black-123 Thanks ...

Unique constraint with JPA and Bean Validation

I'd like to have a @Unique constraint with Bean Validation, but that is not provided by the standard. If I would use JPA's @UniqueConstraint I wouldn't have a unique validation and error reporting mechanism. Is there a way to define @Unique as a Bean Validation constraint and combine it with JPA, such that JPA creates a column with an u...

Generating Order Numbers - Keep unique across multiple machines - Unique string seed

I'm attempting to create an order number for customers to use. I will have multiple machines that do not have access to the same database (so can't use primary keys and generate a unique ID). I will have a unique string that I could use for a seed for some algorithm that will generate a unique looking alphanumeric ID # for the order ...

SQL: How to find duplicates based on two fields?

I have rows in an Oracle database table which should be unique for a combination of two fields but the unique constrain is not set up on the table so I need to find all rows which violate the constraint myself using SQL. Unfortunately my meager SQL skills aren't up to the task. My table has three columns which are relevant: entity_id, ...

How can I do SELECT UNIQUE with LINQ?

I have a list like this: Red Red Brown Yellow Green Green Brown Red Orange I am trying to do a SELECT UNIQUE with LINQ, i.e. I want Red Brown Yellow Green Orange var uniqueColors = from dbo in database.MainTable where dbo.Property == true select dbo.Color.Name; I then changed this to var uniqueColors = from dbo in database.Ma...

Keep sequential primary key in error insert

My create table command in mysql is CREATE TABLE `map` ( `id` int(4) AUTO_INCREMENT NOT NULL, `city` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB; CREATE UNIQUE INDEX `map_city_idx` ON `map` (`city`); Intial value, like: id(1),city('Banda Aceh') id(2),city('Medan') The next insert is city('Medan'), so...

Removing bidirectional duplicates in MySQL

I'm modifying phpBB's table to have bidirectional relationships for friends. Unfortuntately, people that have already added friends have created duplicate rows: user1 user2 friend 2 3 true 3 2 true 2 4 true So I'd like to remove rows 1 and 2 from the example above. Currently, this is my query bu...

Counting unique words in a file? Good Linear Search alternative?

I'm using a naive approach to this problem, I'm putting the words in a linked list and just making a linear search into it. But it's taking too much time in large files. I was thinking in use a Binary Search Tree but I don't know if it works good with strings. Also heard of Skip Lists, didn't really learn it yet. And also I have to use...

PHP: Add Unique ID + Order ID for each word what starts with @

I need to add an Order ID + Unique ID for each word what starts with @. For example I have a string like this: Just @do @it and @do @it. I want to preg_replace #(\@)+([^\s]+)#i to this: Just <div id="1+Unique ID">@do</div> <div id="2+Unique ID">@it</div> and <div id="3+Unique ID">@do</div> <div id="4+Unique ID">@it</div>. ...

Converting a SecureRandom and UUID into an int (java)?

Hello, I am having problems taking in a string (a persons name), and getting back a unique integer, it keeps going through the catch function, and I dont know why, other than the way I wrote SecureRandom is not working, but it is very confusing. I am very new to programming so please be kind! public static int uinqueID(String name){...

PHP providing a closure to determine uniqueness of an item in an array

Quick question: is there a way to provide a closure in PHP to some equivalent function to the array_unique function so that you can specify your own comparison closure to be used when comparing two items in the array? I have an array of class instances (which may contain duplicates) and want to tell PHP to use particular logic to determi...

How do I do 2 unique LEFT JOINs on the same table cell?

Hi, In mysql I'd like to do 2 unique LEFT JOINs on the same table cell. I have two tables. One table lists individual clients and has a clientNoteID and staffNoteID entry for each client. clientNoteID and staffNoteID are both integer references of a unique noteID for the note store in the notesTable. clientsTable: clientID | client...

Referencing inserted elements in a single pass

I'm trying to insert unique IDs and references to those IDs using a single XSLT file. Given the XML: <Parent> <Name>Dr Evil</Name> <Child> <Name>Scott Evil</Name> </Child> </Parent> And this XSLT snippet after an identity transform: <xsl:template match="Parent"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:...

Interpreting an execution plan

Hello, I need some help analysing some simple t-sql execution plans. I have a table [User] with the following 3 columns: Id(Primary Key), Username(nvarchar(50)), FirstName(nvarchar(50)) I have Created an Unique NonClustered Index for the Username column The execution plan for a query filtering by FirstName: select * from [User] where...

Is there unique() function in javascript to remove similar elements in array of numbers ?

I have an array of numbers, like: [1, 4, 7, 1, 2, 1, 3, 1, 4]. I would like to remove duplicate elements and sort the result, i.e. the required result is: [1, 2, 3, 4, 7]. Is there any built in Javascript/jQuery functions to do this, or I must write my own ? ...

Serial generation with PHP

Throughout my days as a PHP Programmer and a beginner at C# programming I've always wondered of the best way to generate unique serials such as how Microsoft Office and Microsoft operating systems do. Does anyone have a good guide to how to handle this, Like what are the important factors in generating the unique serial, prevent duplic...

Counting unique elements in a list

Is there a straight-forward combination of standard higher-order funtions to count the unique elements in a list? For example the result for [1, 1, 4, 0, 4, 4] would be something like [(1,2), (4,3), (0,1)] ...

Python: Uniqueness for list of lists

Hello I am curious what would be an effient way of uniquefying such data objects: testdata =[ ['9034968', 'ETH'], ['14160113', 'ETH'], ['9034968', 'ETH'], ['11111', 'NOT'], ['9555269', 'NOT'], ['15724032', 'ETH'], ['15481740', 'ETH'], ['15481757', 'ETH'], ['15481724', 'ETH'], ['10307528', 'ETH'], ['15481757', 'ETH'], ['15481724', 'ETH']...

How to use ALTER TABLE to add a new column and make it unique?

How do I use ALTER TABLE to add a new column and make it unique? ...