primary-key

Add Primary Key to a table with existing clustered index

I have to work with a database to do reporting The DB is quite big : 416 055 104 rows Each row is very light though, just booleans and int ids. Each row is identify by 3 columns, but at my surprise, there is no Primary Key on it. Only a Clustered Index with a unique constraint. So Knowing that, I have 2 question. Could there be ANY g...

AppEngine Primary Keys

Hi, by default, GAE adds a unique key to your db entries. Is it possible to have a numeric unique key in addition? Elias ...

MySQL - how to use VARCHAR as AUTO INCREMENT Primary Key

I am using a VARCHAR as my primary key. I want to auto increment it (base 62, lower/upper case, numbers), However, the below code fails (for obvious reasons): CREATE TABLE IF NOT EXISTS `campaign` ( `account_id` BIGINT(20) NOT NULL, `type` SMALLINT(5) NOT NULL, `id` VARCHAR(16) NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=MyISAM ...

How can I create an error for primary-key ?

Hello, I have a form where the primary-key must be filled by the user. But if he enters a value existing, I have the page with doctrine error 'Integrity constraint violation: 1062 Duplicate entry'. I want to make an error message as the other key with $form['myKey']->renderError() I have tried to use sfValidatorDoctrineChoice : $t...

Primary Key - VARBINARY or BLOB or VARCHAR for UUID primary key

I am using UUID as the primary key in one of the tables. What are the pros-cons of having this field as a varchar/varbinary/blob? DB: MYSQL. TIA ...

Update column value or delete it if duplicated?

I have a MySQL table which has three columns: Authority | MapID | Time --------------------------------------------------------- animuson@forums | 000000000000000 | 45.6758 132075829385895 | 000000000000000 | 49.7869 qykumsoy@forums | 000000000000000 | 44.45 439854390263565...

ManyToMany relationship using JPA with Hibernate provider is not creating primary keys

I've created two JPA entities (Client, InstrumentTraded) using Hibernate as a provider that have a ManyToMany relationship. After letting Hibernate generate the tables for MySQL it appears that the ManyToMany relationship table does not contain primary keys for the two foreign keys. This allows duplicate records in the many-to-many tab...

why must a primary key be minimal?

A primary key is an attribute or set of attributes that uniquely identifies a row in a table. But a primary key has not only to be unique, but also minimal. Why is that necessary? ...

spring 3 security schema username as primary key?

I Googled for this, but I couldn't find an answer anywhere. Why does the Spring 3 Security schema (http://static.springsource.org/spring-security/site/docs/3.1.x/reference/appendix-schema.html) have a username as a primary key instead of an integer guid? People often suggest that using "natural" usernames as your pk is bad practice. ...

Multiple primary keys in a schema

I have this schema which I need to define two primary keys; one is Drupal's 'vid' field and the other one is my site 'bid' field which is of auto increment type which in turn requires it to be a primary key: wtherwise I get MySQL error. I'm having trouble finding syntax for defining multiple primary keys in a Drupal schema. If anyone can...

Why do I read so many negative opinions on using composite keys?

I was working on an Access database which loved auto-numbered identifiers. Every table used them except one, which used a key made up of the first name, last name and birthdate of a person. Anyways, people started running into a lot of problems with duplicates, as tables representing relationships could hold the same relationship twice o...

How to get names of the table attributes?

Hi friends, I am working Sql Server 2005 My table name is Customer, the attributes are Orderid Customerid Customeraddress Wherein Customerid is the primary key and Orderid is the foreign key. I want to know the primary key name, foreign key name and the table name where the foreign key exists as a primary key Is there any query to...

MS Access: How can one find "qualifier" and "owner"

This may seem like a stupid question, but rest assured that I don't need general database help, but MS Access help specifically. This would not be a problem if I were working with any other database. I need to fish out the primary key(s) form an MS Access table using PHP with an ODBC connection. I have found two PHP functions that suppo...

How to map HasMany using non Primary Key column?

Hi I use Castle.ActiveRecord's HasMany mapping. I have something like: [HasMany (typeof (childtype), ColumnKey = "this_relation_column", Table = "childtype_table")] I would like to use a different column on childtype_table to relate with this_relation_column. Actually, this_relation_column is of type text (string), and the PK of child...

Stupid Question: MSSQL Management Studio 2008 - Database Diagrams - Which way do the keys point?

Yeah silly question. Its been a long time since I have designed a DB as a Database Diagram but the higher ups want to see it. I have totally become confused because I am a coder, not a DBA. I have a main table which contains user id, name, username, password, etc. This main table has the primary key of ID. Should sub tables (such as add...

Violation of Primary Key constraint error

I am using SSMS 2008 and trying to insert with this query but am getting the following error: Msg 2627, Level 14, State 1, Line 1 Violation of PRIMARY KEY constraint 'PK_j5c_MasterMeasures'. Cannot insert duplicate key in object 'dbo.j5c_MasterMeasures'. The statement has been terminated. Here is my query: insert into J5C_MasterMeasu...

MySQL table PRIMARY KEY question?

I' was wondering should my primary key look like this PRIMARY KEY (id, category_id, posts_id) or look like this PRIMARY KEY (id)? Here is my MySQL table. CREATE TABLE posts_categories ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, category_id INT UNSIGNED NOT NULL, posts_id INT UNSIGNED NOT NULL, date_created DATETIME NOT NULL, PRIMARY KEY...

How to get primary key after calling ActiveRecord save() method PRADO?

Hi, I am starting out with PRADO php framework and i have a quick question: How to get the Primary Key of the last inserted record? My codes are as follow: $studentRecord = new StudentRecord; $studentRecord->Name = $this->txtName->SafeText; $studentRecord->ContactNumber = $this->txtContactNo->SafeText; $studentRecord->save(); // $stude...

PLINQO Primary key AND index problem

Hi, I've two tables, Profile and ProfileCategory ProfileId INT IX UserId UNIQUEIDENTIFIER PK (For one-to-one mapping with aspnet_membership) CompanyName Description ProfileCategory CategoryId ProfileId When I generate the code with PLINGO I get following errors Operator '==' cannot be applied to operands of type 'int?' and 'System....

PHP-ORACLE: take the autogenerated ID after an insert

i have a Oracle Express 10g database, i have a table with an autogenerated id, i whold like to know how can i know it in php after an insert. ...