primary-key

SQL Server - Noob Relationships Question

I have two tables: CREATE TABLE InmarsatZenith.dbo.ClientJob (JobRef int PRIMARY KEY NOT NULL, IntRef uniqueidentifier, CopyDeadline datetime, PublicationDate datetime, Repeat bit, BusinessType nvarchar(25), Sector nvarchar(30), Lang nvarchar(15), Format nvarchar(25), CreativeRotation nvarchar(50), TipinType nvarchar(25)) and CREATE ...

Composite primary key: to use or not to use

I am working on the design of a database that will be used to store data that originates from a number of different sources. The instances I am storing are assigned unique IDs by the original sources. Each instance I store should contain information about the source it came from, along with the ID it was associated by this source. As an...

primary key violation if case sensitive

Suppose I've the 'dom' table which contains two fields code name Code should be primary key. In case if I enter values('SD', 'domnic') then again if I enter ('SD', 'domnic1') in asp.net I've wrote validation so i can receive alert message. protected void ButtonSave_Click(object sender, EventArgs e) { try { if (Mode ...

Prevent Typed DataSet updating PK column

I have a typed dataset, and where I call TableAdapter.Update(DataRow), the SQL executed includes an update of the primary key column of the database. Unfortunately, when this code runs on a replicated database, the PK column has the rowguid property set, and I get the following error: System.Data.SqlClient.SqlException: Updating col...

SQL 2005: Keys, Indexes and Constraints Questions

I have a series of questions about Keys, Indexes and Constraints in SQL, SQL 2005 in particular. I have been working with SQL for about 4 years but I have never been able to get definitive answers on this topic and there is always contradictory info on blog posts, etc. Most of the time tables I create and use just have an Identity colu...

Compound primary key in Table type variable

SQL Server 2008: DECLARE @MyTable TABLE( PersonID INT NOT NULL, Person2ID INT NOT NULL, Description NVARCHAR(100), CONSTRAINT PK PRIMARY KEY CLUSTERED (PersonID, Person2ID) ); Gives: Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'CONSTRAINT'. Is there any way to have compound Primary key in Table ...

Mapping a Natural Key with Hibernate Annotations

Hi, I have a legacy table that uses a column that holds a date as the natural prmary key to the table. I am trying to map this with hibernate, but for the life of me I can't figure out how to get hibernate to map a single (none-compound) natural key as the Id. I have it mapped like this: @Id @Temporal(TemporalType.TIMESTAMP) @Column(...

ORA-02437: cannot validate <name> - primary key violated

Hi, I have a table: CREATE TABLE MY_TABLE ( MY_ID NUMBER NOT NULL, COLUMN_1 NUMBER, COLUMN_2 NUMBER ); ALTER TABLE MY_TABLE ADD CONSTRAINT PK_FOO PRIMARY KEY (MY_ID); at a later point, when executing the following sql, I get an error: ALTER TABLE MY_TABLE DROP PRIMARY KEY DROP INDEX; ALTER TABLE MY_TABLE ADD CONSTRAINT PK_FOO P...

Composite Primary Key performance drawback in MySQL

We have a table with a composite Primary key consisting of three fields (and it is in MySQL 5.1). There are near 200 inserts and 200 selects per second on this table, and the size of the table is around 1 million rows and it is increasing. My question is, does the "Composite Primary Key" decrease the performance of the Inserts and Select...

Problem generating primary key with SSIS

Hi! I am with my boss and we are having a problem with an SSIS project. Are DataModel sucks and doesn't have a automatic primary key so we have to do the classic and nasty Select Max(id) + 1 from customer The problem is that from the moment that my script task generate the PK to the moment I insert there are 10 rows that has been tu...

SubSonic PrimaryKey not autoincrement

Does current version of SubSonic support PrimaryKey (Int) which is not Autoincrement? How? PS: If I don't use SimpleRepository() I can save new record with assigned Id so more or less I can go on, thz. ...

How can I get ASP.NET MVC's UpdateModel to ignore primary key colum?

I have a table with a GUID primary key into which I'm trying to insert a newly-created object using an ASP.NET MVC Controller's UpdateModel method (db is a LINQ-to-SQL data context): [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection) { Fields field = new Fields(); field.ID = G...

Using a System.Guid as primary key in ASP.Net MVC?

I have created a table in the database that has a System.Guid as it's primary key. The required ADO.Net Entity Framework model has been generated and the required stored procedures has been mapped. I created a new controller and added the basic required code for Create and Edit for the data. However when the clicking on the link to edit...

.Net DbDataAdapter has wrong primary key on filled datatable and i want to correct this

Hi all, .NET/MSSQL Server Question: I use a System.Data.SqlClient.SqlDataAdapter to connect to a database and read (.Fill) a datatable from a view in the database (select * from v_coolview). The problem is that the view consists of multiple tables (of course) and the resulting DataTable has typically a primary key set (Datatable.Primar...

How to use MySQL index columns?

When do you use each MySQL index type? PRIMARY - Primary key columns? UNIQUE - Foreign keys? INDEX - ?? For really large tables, do indexed columns improve performance? ...

Entity Framework Multiple Table Entity Key Mapping issue

Ok so here is my issue. I have a QA day log table and a Employee table. I want the NetUserID on the Employee table to be transfered to the QA day log table. I added both tables, cut and pasted in the designer and I edited the mappings like I thought I was supposed to. I get an error about the DL_ID which is the primary key for the QA...

Determine a table's primary key using TSQL

I'd like to determine the primary key of a table using TSQL (stored procedure or system table is fine). Is there such a mechanism in SQL Server (2005 or 2008)? ...

Performace enhancements for tables

With MySQL I often overlook some options like 'signed/unsigned' ints and 'allow null' but I'm wondering if these details could slow a web application down. Are there any notable performance differences in these situations? using a low/high range of Integer primary key 5000 rows with ids from 1 to 5000 5000 rows with ids from 20001 to...

In ORACLE, How do I determine the fields that compose the primary keys of tables or views?

I'm doing an heterogeneous replication app in Django and need to determine the primary key fields of the tables that are going to get sync'ed. ...

entity-framework a table without a unique key

There is a table in a database that i can't change i'm trying to use with Entity Framework. For sake of argument, there is no unique key possible, not even all the columns, all the columns are of type nvarchar(x), and i can't change the database to include a rownumber type column. Is there any way to get this table into Entity Framework...