Re: Best way to normalize data from two tables
Posted by: Peter Brawley
Date: December 10, 2013 01:06PM

Lose the names column in the main table.

create table main(id int primary key, ...);
create table names(
  id int primary key, 
  mid int, 
  name char(16),
  foreign key(mid) references main(id) on update cascade on delete cascade
);
Retrieve names with a join ...

select main.id, group_concat(names.name)
from main
join names on main.id=names.mid
group by main.id;

Options: ReplyQuote


Subject
Written By
Posted
Re: Best way to normalize data from two tables
December 10, 2013 01:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.