On Tue, 8 Jul 2008, Aditya wrote: > Date: Tue, 08 Jul 2008 09:21:35 -0000 > From: Aditya <[EMAIL PROTECTED]> > Reply-To: [email protected] > To: [email protected] > Subject: [twincling] problem with INSERT INTO .... SELECT .... usage in > postgresql > > Hi, > I am new to postgresql. I have a small problem. I have two tables 1) > students and 2) classes with the following structure - > > Students - > 1) roll_no > 2) name > 3) class > > and Classes - > 1) roll_no > 2) class > > with roll_no being primary key in both the tables. > >
Hi Aditya: roll_no *cannot* be primary key in both the tables. A student has a roll_no and to use it in the Classes table, you need to post 'roll_no' as a foreign key. This is basic referential integrity constraint in relational databases. Please see http://en.wikipedia.org/wiki/Referential_integrity thanks Saifi.

