primary-key

Database Design and the use of non-numeric Primary Keys

拜拜、爱过 提交于 2019-12-18 14:56:52
问题 I'm currently in the process of designing the database tables for a customer & website management application. My question is in regards to the use of primary keys as functional parts of a table (and not assigning "ID" numbers to every table just because). For example, here are four related tables from the database so far, one of which uses the traditional primary key number, the others which use unique names as the primary key: -- -- website -- CREATE TABLE IF NOT EXISTS `website` ( `name`

Database Design and the use of non-numeric Primary Keys

荒凉一梦 提交于 2019-12-18 14:56:03
问题 I'm currently in the process of designing the database tables for a customer & website management application. My question is in regards to the use of primary keys as functional parts of a table (and not assigning "ID" numbers to every table just because). For example, here are four related tables from the database so far, one of which uses the traditional primary key number, the others which use unique names as the primary key: -- -- website -- CREATE TABLE IF NOT EXISTS `website` ( `name`

Algorithm for unique CD-KEY generation with validation

爱⌒轻易说出口 提交于 2019-12-18 13:38:52
问题 I am trying to create a unique CD-KEY to put in our product's box, just like a normal CD-KEY found in standard software boxes that users use to register the product. However we are not selling software, we are selling DNA collection kit for criminal and medical purposes. Users will receive a saliva collection kit by mail with the CD-KEY on it and they will use that CD-KEY to create an account on our website and get their results. The results from the test will be linked to the CD-KEY. This is

Primary key id reaching limit of bigint data type

女生的网名这么多〃 提交于 2019-12-18 13:27:43
问题 I have a table that is exposed to large inserts and deletes on a regular basis (and because of this there are large gaps in the number sequence of the primary id column). It had a primary id column of type 'int' that was changed to 'bigint'. Despite this change, the limit of this datatype will also inevitably be exceeded at some point in the future (current usage would indicate this to be the case within the next year or so). How do you handle this scenario? I'm wondering (shock horror)

UUID versus auto increment number for primary key

爷,独闯天下 提交于 2019-12-18 13:02:44
问题 Why should I choose UUID over an auto increment number for my entity's primary key? What are the pros and cons? 回答1: Andrey and Mjg both had good points, but I would add a related performance issue that is significant. With the decoupling of database and key generation also allows applications that have complex relationships between objects to create them all with the keys in place, so that bulk inserts are possible. In the case of auto-increment, all of the objects that own relationships (ie

PRIMARY KEY issue with creating tables in Rails using rake db:migrate command with mysql

戏子无情 提交于 2019-12-18 12:52:57
问题 My version of rails is 4.0.0, my version of mysql is Ver 14.14 Distrib 5.7.9, for Win64 (x86_64). I am operating of an older version of rails as I was getting some clashes with the mysql as per my previous question Here. (check Kalelc's approved answer for my recourse) upon running rake db:migrate I get the following error == CreateUsers: migrating ==================================================== -- create_table(:users) rake aborted! StandardError: An error has occurred, all later

How do I determine if a column is in the primary key of its table? (SQL Server)

家住魔仙堡 提交于 2019-12-18 11:48:04
问题 I am currently using... select Table_Name, Column_name, data_type, is_Nullable from information_Schema.Columns ...to determine information about columns in a given database for the purposes of generating a DataAccess Layer. From where can I retrieve information about if these columns are participants in the primary key of their table? 回答1: Here is one way (replace 'keycol' with the column name you are searching for): SELECT K.TABLE_NAME , K.COLUMN_NAME , K.CONSTRAINT_NAME FROM INFORMATION

What is the difference b/w Primary Key and Unique Key

断了今生、忘了曾经 提交于 2019-12-18 10:50:46
问题 I tried to find it out in google but not satisfactory answer is given out there. Can anybody explain the solid difference. actually if Primary key is used to select data uniquely then what is the need of Unique key? When should I use a Primary key and when to use a Unique key? 回答1: Primary Key and Unique Key are used for different things - understanding what they are for will help you decide when to use them. The primary key is used to identify a row of data in a table. It is used whenever

Is it a bad idea to use GUIDs as primary keys in MS SQL?

随声附和 提交于 2019-12-18 10:08:23
问题 We have a system that uses UniqueIdentifier as the primary key of each of the tables. It has been brought to our attention that this is a bad idea. I have seen similar post on the subject but I am interested in any MS SQL performance and other potential problems I may encounter due to this decision. 回答1: There are pros and cons: This article covers everything. GUID Pros Unique across every table, every database, every server Allows easy merging of records from different databases Allows easy

Updating MySQL primary key

无人久伴 提交于 2019-12-18 09:58:41
问题 I have a table user_interactions with 4 columns: user_1 user_2 type timestamp The primary key is (user_1,user_2,type) and I want to change to (user_2,user_1,type) So what I did was : drop primary key ... add primary key (user_2,user_1,type)... and voila... The problem is that database is live on a server. So before I could update the primary key, many duplicates already crept in, and they are continuously creeping in. What to do? What I want to do now is to remove duplicates and keep the ones