views:

48

answers:

2

Can we define a string and a number both as a primary Key in table?

+2  A: 

Yes. But depending on the RDBMS I wouldn't necessarily do that.

Instead create a surrogate primary key, and a unique compound key based on your domain values (string and number)

Mitch Wheat
A: 

Yes. In principle it ought to be possible to use any combination of attributes as a key or keys in a table (assuming nulls aren't permitted). In practice most SQL DBMSs place limits on the storage size and sometimes the types that can be used.

dportas