primary-key

alternative to GAE Keys for mySQL ?

Hi all, wondering if the GAE keys (com.google.appengine.api.datastore.Key) can be used with local mysql apps? I presume it's not possible, so if I define my primary keys in my models as longs, do I lose too much of the key functionality, like the KeyService and querying using keys ? Thanks ...

Refactor Foreign Keys with Update after Primary Key change

We ran into a problem with out primary key. It was set to a meaningful value for ease of data entry since all data was originally added directly. However now the meaningful value is not always present in all entries. So now we are moving to an auto-generated, non-meaningful key. But I have to update the database to reflect this. So ...

Normalization is better or composite primary key is better???

Hi, I have a table in Oracle DB,say, Student table. StudentID is the primary key in the table.I have another column interested subjects,say columns name is interested_SUB. A student can have more than one interested subject. In this case, I have the following 2 options: 1) Having the StudentID and Interested_SUB columns as the composite...

sqlite: multi-column primary key with an auto increment column

I basically want to convert a table from mysql to sqlite with the following scheme: create table items ( id integer auto_increment, version integer default 0, primary key (id, version) ); Essentially, I want ID to auto increment whenever I insert anything into the table, with VERSION starting off at 0, but still allow multiple items w...

Default Index on Primary Key

Does the SQL Server build an index on primary keys by default? If yes what kind of index? If no what kind of index is appropriate for selections by primary key? I use SQL Server 2008 R2 Thank you. ...

Creating django objects with a random primary key

Hi guys! I'm working with an API that wants me to generate opaque "reference IDs" for transactions with their API, in other words, unique references that users can't guess or infer in any way. (is 'infer' proper english?) This is what I've hacked together currently: randomRef = randint(0, 99999999999999) while Transaction.objects.filt...

Setting indexed columns on a custom SQL table

Hi, I've read about primary, unique, clustered indexes etc. But I need to understand it via an example. The image below is the auto-generated aspnet_Users table captured from SQL Server Web Admin Panel. Taking this as a model; I will create a custom table called Companies and let's say the fields are: ID, Name, ShortName, Address,...

Is it bad to have meaningless keys in my domain model classes?

When creating domain model, we almost always have Id field or property for our entities which represents the primary key column of corresponding table in the database. My question is - if I have this key property that has nothing to do with the domain model (in other words, it's just database concern; Martin Fowler prefers to name it mea...

changing the primary key value in SQL server 2005

I have a Table which has a Primary Key field which is not set to auto-increment. I want to change one of these primary keys to something different. The problem arises with the other tables relations. The thing is, the guy who built this system did not build relations in SQL Server, but rather manually coded some override in the program ...

Why does Access want you to identify a primary key on linked tables?

Supporting users who use MS Access as a front-end for viewing some Oracle tables at our intstitution. Typical use is to write ad-hoc queries with the Access querybuilder, and also they LOVE Access because it lets them build printable reports without having to submit to the lengthy & expensive programming-request process through our tech...

Is an index needed for a primary key in SQLite?

When an integer column is marked as a primary key in an SQLite table, should an index be explicitly created for it as well? SQLite does not appear to automatically create an index for a primary key column, but perhaps it indexes it anyway, given its purpose? (I will be searching on that column all the time). Would the situation be any d...

How does SQL Server store a composite primary key?

The limit of my understanding how a database stores a primary key is a btree based on the clustered key with each node storing the rest of the columns. I have not updated this understanding since university last century and would love to know how SQL Server stores a composite primary key compared to a single primary key. Can anyone hel...

SQLite - Is it possible to make a non-integer Primary Key work?

Thanks for reading and hopefully answering, Due to legacy issues and company policy, I am working with SQLite 2.8.17 and have a few varchars as primary keys. But when I run a *"pragma integrity_check"*, it reports "rowid missing from index" and "wrong # of entries in index" on the tables with the varchar primary key but the returned re...

symfony : forms and primary keys

Hello, I have a form and when I want to set the primary key, I have an error 'Invalid' after the form's validation. My widget : $this->widgetSchema['nud'] = new sfWidgetFormInput(); And my validator : 'nud' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('nud')), 'empty_value' => $this->getObjec...

Entity Framework CTP4 non-standard primary key name usage in BaseEntity

I am struggling already several days to solve my problem with primary key usage. Please, someone help me to solve this puzzle!!! I am using Entity Framework with CTP4 using Code First approach. I adopted for my project Repository pattern published by Huyrua see here. I am very exited with this patern and with CTP4 possibilities in parti...

Values missing in postgres serial field

Hi I run a small site and use PostgreSQL 8.2.17 (only version available at my host) to store data. In last few months there were 3 crashes of database system on my server and every time it happened 31 ID's from serial field (primary key) in one of the tables were missing. 93 ID's are missing now. Table: CREATE TABLE "REGISTRY" ( "ID" ...

how to get primary key column names for a given table ?

All I know is only table name, and id value on which I want to perform query, but I do not know what is id called in that table. ...

Looking for a good method of extending external data with an internal database table

I have an application that receives most of its data from a third party. One of these sets of data is a transaction list. I can't write to this service, but I want to add more information to that data for use in my own application. I intend to do that with a SQL table with extended info. The problem is that the third-party data does ...

symfony : Problem 'Integrity constraint violation' with primary key

Hello, When I want to create a new object with one of my form, Doctrine take me an error : Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' Creating worked previously, but I don't know what I have change to have an error now. My schema for ID : Logement: connection: doctrine actAs: [Timestampable] ta...

Entity Framework Foreign Key Issue

I am getting a very frustrating issue: System.Data.UpdateException was unhandled by user code Message="Entities in 'MyProjectEntities.GroupingData' participate in the 'FK_GroupingData_AuditTrail' relationship. 0 related 'AuditTrail' were found. 1 'AuditTrail' is expected." This happens when I try to add an object to the data...