FAQ Database Discussion Community


MySql - Is primary key unique by default?

mysql,primary-key,unique-key
If I define a column as a primary key in MySql, is it also unique key by default or do I need to also define it as unique key (in case I want it to be unique)? I saw this question What is the difference b/w Primary Key and Unique...

PHP UNIQUE user movie rating

php,mysql,unique-key
On my site when a user is logged in, they can give a 1-5 rating on a movie. What I want to do is make it so that database knows which user gave the rating and to update there rating if they click it again rather than creating a new...

Can a unique key ( not a primary key) be a foreign key to other table?

oracle,foreign-keys,primary-key,unique-key
I have two table students and studentsprofilepic 'username' from students is unique key of the table it is referenced as foreign key for the 'studentsprofilepic' table the DDL for the tables are create table students( id number, username varchar2(30), password varchar2(30), firstname varchar2(30), lastname varchar2(40), email varchar2(300), dob varchar2(20), alt_email...

Solr 5.1.0: How to set the unique key via Schema API

solr,schema,unique-key
In Solr 5.1.0, is it possible to set the unique key via the REST schema api? I created a collection with the data driven schema. Solr would guess what the field type and create the field based on the data I upload. I can still define fields beforehand by sending...

Generating a 'unique' 3 character tag from 4 Hex digits

linux,bash,raspberry-pi,unique-key
I'm working on a project using Raspberry Pi in a stateless net booted environment for a local museum. I want the Raspberry Pi to generate an easy to remember 3 character code from the last 4 digits of the MAC address. This code will be read by a person and...

How to generate unique secure random string in PHP?

php,unique-key
I want to add random string as token for form submission which is generated unique forever. I have spent to much time with Google but I am confused which combination to use? I found so many ways to do this when I googled: 1) Combination of character and number. 2)...

In Cassandra, if I run a query that increments a counter, then selects from that counter is that atomic?

cassandra,counter,cql,unique-key
If I run a query that increments a counter, then selects from that counter is that atomic? I am wanting to generate smaller (integer) numbers using Cassandra. The usage will likely be generating fewer than 1000 Ids/day, but definitely needs to be non-conflicting, and would prefer minimal chance of waste...