0

How can I merge/store the common names in a single row?

I'm trying to set up a satellite database. In my current MS SQL 2014 database the satellites have multiple common names.

I was thinking of a comma seperated list, but after reading this Is storing a delimited list in a database column really that bad? I don't think it's a good idea.

sat_id  off_name    common_name norad_nr    cospar_nr   operator_country
39325   NAVSTAR 66      NAVSTAR 66      37753   2011-036A   US        
39326   NAVSTAR 66      USA 232         37753   2011-036A   US        
39327   NAVSTAR 66      GPS BIIF-2      37753   2011-036A   US        
39328   NAVSTAR 66      GPS 2F-2        37753   2011-036A   US        
39329   NAVSTAR 66      SVN 63          37753   2011-036A   US        
39330   NAVSTAR 66      PRN 01          37753   2011-036A   US        
39331   NAVSTAR 66      SLOT D2         37753   2011-036A   US        
Community
  • 1
  • 1
Frank
  • 99
  • 1
  • 6

1 Answers1

0
create table satellite
(   satId int auto_increment primary key,
    satName varchar(200) not null
);

create table satAKA
(   id int auto_increment primary key,
    satId int not null,
    akaName varchar(200) not null,
    CONSTRAINT fk_aka_sat
        FOREIGN KEY (satId) 
        REFERENCES satellite(satId)
);

insert satellite (satName) values ('Cisco Teleride Model 7000'),('Norad Spectro Tracker');

-- you know have 2 satellites

insert satAKA(satId,akaName) values (1,'Cisco Teleride Model 7000');
insert satAKA(satId,akaName) values (1,'Cisco T Green Monster');
insert satAKA(satId,akaName) values (1,'Green N. Korean Missile Finder');

insert satAKA(satId,akaName) values (2,'Norad Spectro Tracker');
insert satAKA(satId,akaName) values (2,'Nrd Wyoming Peace');
insert satAKA(satId,akaName) values (2,'Western Overpriced Scrap Metal');
Drew
  • 24,851
  • 10
  • 43
  • 78
  • oh look now i screwed up! The mysql tag was removed. Please convert to IDENTITY, etc (FK) accordingly, sorry ! – Drew Jul 15 '15 at 14:27