Re: Merge Record in Database(SQL Statement)

From: "listrec" <listrec(at)epecon(dot)de>
To: "Shahbuddin Md Isa" <shahi(at)unitar(dot)edu(dot)my>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Merge Record in Database(SQL Statement)
Date: 2003-07-07 09:19:07
Message-ID: PCEJJIGCHIJCOOOGFAFEKEOGCAAA.listrec@epecon.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Not quite sure what the question is....

Assuming, you would like to normalize the data, I suggest to create 4
tables:

create table gpa (id integer primary key,gpa varchar(32) not null unique);
create table major (id integer primary key,major varchar(32) not null
unique);
create table birthplace (id integer primary key,birthplace varchar(32) not
null unique);
create table xxx (
id integer primary key,
attributename varchar(64) not null, -- this might be unique too
id_major integer references major(id),
id_birthplace integer references birthplace(id),
id_gpa integer references gpa(id)
);

insert into gpa (id,gpa) values (1,'excellent');
insert into major (id,major) values (1,'science');
insert into birthplace (id,birthplace) 1,'India');

insert into xxx (id,attributename,id_major,id_birthplace,id_gpa) values
(1,'Record 1',1,1,1);
insert into xxx (id,attributename,id_major,id_birthplace,id_gpa) values
(1,'Record 2',1,1,1);

Now selecting the records would be something like:

select x.attributename,m.major,b.birthplace,g.gpa from attributename a,major
m,birthplace b,gpa g
where x.id_major=m.id and x.id_birthplace=b.id and x.id_gpa=g.id

Hope that helps....

Detlef

-----Ursprüngliche Nachricht-----
Von: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org]Im Auftrag von Shahbuddin Md Isa
Gesendet: Montag, 7. Juli 2003 03:24
An: pgsql-sql(at)postgresql(dot)org
Betreff: [SQL] Merge Record in Database(SQL Statement)

Hai..

How to merge record in database(sql statement) if record same attribute,
examples:-

Attribute Major Birth_Place GPA

Record 1 science India excellent
Record 2 science India excellent

Please help me..

____________________________________________________________
Powered by Fastmail from http://www.i-fastmail.com

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gary Stainburn 2003-07-07 11:40:23 create view error
Previous Message Markus Bertheau 2003-07-07 05:21:19 Re: Merge Record in database(sql statement)