primary-key

Cayenne, Postgres: primary key generation

一笑奈何 提交于 2019-12-08 13:10:10
问题 I'm using Cayenne 3.2M1 and Postgres 9.0.1 to create a database. Right now I'm having problems with the primary key generation of Cayenne since I have tables with more than one primary key and as far as I've read Cayenne cant generate more that one primary key per table. So I want the Postgres to do that work. I have this table: CREATE TABLE telefonocliente ( cod_cliente integer NOT NULL DEFAULT currval('cliente_serial'::regclass), cod_telefono integer NOT NULL DEFAULT nextval(

Primary key check in django

怎甘沉沦 提交于 2019-12-08 12:54:18
问题 I have this custom primary key in a model: class Personal(models.Model): name = models.CharField(max_length=20,primary_key=True) email = models.EmailField(blank=True,null=True) Now the thing i m not getting is, how can i create my view so that no duplicate record is entered? I searched this over online, but could find any technique to get the view created. here is the code for views def uregister(request): errors = [] if request.method == 'POST': if not request.POST.get('txtName', ''): errors

having three different triggers for the same table when need an unique id for insert

旧巷老猫 提交于 2019-12-08 11:52:21
问题 I have a table POI for Points of Interest with 3 triggers. One get geografic information. State, City, Street based on X,Y. Second do some validation on the field content and raise error if any violation. Third create audit record about what change and who make the change. This table used to be handle using mapinfo so before been inserted they have a unique generated id created for mapinfo. Now we are moving to QGIS and this program doesnt have an unique id. By my understanding oracle before

SQL Index - Difference Between char and int

大兔子大兔子 提交于 2019-12-08 11:37:36
问题 I have a table on Sql Server 2005 database. The primary key field of the table is a code number. As a standard, the code must contain exactly 4 numeric digits. For example: 1234, 7834, ... Do you suggest that field type to be char(4) or int or numeric(4) in terms of effective select operation. Would indexing the table on any type of these differ from any other? 回答1: Integer / Identity columns are often used for primary keys in database tables for a number of reasons. Primary key columns must

Sql Server what to do to make collation key from a string value

好久不见. 提交于 2019-12-08 09:45:35
问题 I receive data files from a source I have no control over (the government) and in the records they have a Company Name field that I actually need to associate with existing company records in my database. I'm concerned that some of the names will vary by minor differences such as 'Company X, Inc.' vs 'Company X Inc'. So my initial thoughts would be to create a collation key field based on the name ToLower() and apply a regex to strip out all white space, and special characters. Is there any

In Android, does _id have to be present in any table created?

ε祈祈猫儿з 提交于 2019-12-08 09:31:15
问题 I am trying to create a table to only has a foreign key, not a primary key. I am getting this error: java.lang.IllegalArgumentException: column '_id' does not exist I read a tutorial that the primary key must be _id, with no explanation. And that is fine. But what if I do not want a primary key! What if I only want a foreign key. I am assuming this is where my problem lies. The schemas below are what I have. But the third one is where I assume this is coming from. database.execSQL("CREATE

Can a multivalued attribute have a primary key?

女生的网名这么多〃 提交于 2019-12-08 09:06:37
问题 Functional dependencies are the attributes that their values are determined in a unique way by another attribute.Given that, can a multivalued attribute be dependent upon a primary key? 回答1: "FDs are the attributes that their values are determined in a unique way by another attribute" is unintelligible. Find a way to say it correctly or how can you understand it? An attribute (or set of attributes) is functionally determined by a set of attributes. There is no such thing as a "multivalued

how to insert foreign key in a table

匆匆过客 提交于 2019-12-08 08:53:54
问题 I just want to make sure that I understand PRIMARY and FOREIGN key relation before searching for some finished answers on the internet. Let's say this: We have table CITY(ID-PK,CODE,NAME) and we have table PERSON(ID-PK,NAME,LASTNAME,CITY_ID-FK) I'm confused, if in this case user needs to enter a foreign key in the table person? If not how know which city needs to be applied to the user? If user needs to enter a foreign key why to have it then because in that way we are leaving a lot of space

How to generate the primary key in DB2 (SQL Optimization)

匆匆过客 提交于 2019-12-08 06:18:56
问题 I use the following statement to generate my primary key. table2 keeps the curent primary key. But it is too slow. How can i optimize this proces. update table1 t set ID =ROW_NUMBER() OVER (); update table1 t set ID = (Select NUMGEN.currentvalue + ID from table1 data, table2 NUMGEN where NUMGEN.tablename = 'table1' and t.Id = data.ID ); 回答1: Why are you doing primary keys this way. Why would you need to dynamically generate/modify your own id values? If you need a unique generated id for a

How can I create a sqlalchemy column whose default is to be equal to the primary key?

最后都变了- 提交于 2019-12-08 03:17:27
问题 I have a class that looks like this: class Foo(Base): pk = Column(Integer, Sequence('foo'), primary_key=True) I want to make another field, ref , that defaults to being equal to pk for newly-created objects. Unfortunately, I'm using Postgres, which has a non-standard nextval() function, so I can't simply make both of the columns default to the Sequence object. Here's my current solution: class Foo(Base): pk = Column(Integer, Sequence('foo'), primary_key=True) ref = Column(Integer, index=True,