
Hi, My database table looks like this *TransactionID* *TransactionNo * *Register* 1 23/2009 Probate 2 23/2009 Administration 3 25/2009 Finance 4 26/2009 Strategy TransactionID is the primary key and is autogenerated. A register can only hold a unique TransactionNo though different registers can share the same TransactionNo. Is there a way that I can make TransactionNo field to be unique, and is there a way of coming up with a Primary Key Alias to represent the unique TransactionNo for each Register? Regards. Ouya Obunga

alter table *table_name* add unique (*TransactionNo, **Register); *it will create a compound key that gurantees that only one combination of transactionNo and Register is allowed* chris * On Tue, Oct 27, 2009 at 11:28 AM, Ogure Obunga <write2ogush@gmail.com>wrote:
Hi,
My database table looks like this
*TransactionID* *TransactionNo * *Register* 1 23/2009 Probate 2 23/2009 Administration 3 25/2009 Finance 4 26/2009 Strategy
TransactionID is the primary key and is autogenerated. A register can only hold a unique TransactionNo though different registers can share the same TransactionNo. Is there a way that I can make TransactionNo field to be unique, and is there a way of coming up with a Primary Key Alias to represent the unique TransactionNo for each Register?
Regards.
Ouya Obunga
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general

On Tue, Oct 27, 2009 at 11:38 AM, Chris Mwirigi <mwirigic@gmail.com> wrote:
alter table *table_name* add unique (*TransactionNo, **Register);
*it will create a compound key that gurantees that only one combination of transactionNo and Register is allowed*
*
Chris, how does he take care of the primary key alias???? I presume that would be the Transaction ID which has to be unique for the composite key???

transactionID will remain unique for each record since it is set to auto_increment the question is, is the table supposed to hold more than one entry for a singe register? if that is the case then the table is not normalized and a seperate table for registers might be required. On Tue, Oct 27, 2009 at 11:43 AM, kennedy kariuki <kkairu@gmail.com> wrote:
On Tue, Oct 27, 2009 at 11:38 AM, Chris Mwirigi <mwirigic@gmail.com>wrote:
alter table *table_name* add unique (*TransactionNo, **Register);
*it will create a compound key that gurantees that only one combination of transactionNo and Register is allowed*
*
Chris,
how does he take care of the primary key alias???? I presume that would be the Transaction ID which has to be unique for the composite key???
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
participants (3)
-
Chris Mwirigi
-
kennedy kariuki
-
Ogure Obunga