If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Database Design Help Needed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-30-09, 00:44
rehanazher rehanazher is offline
Registered User
 
Join Date: Jan 2009
Posts: 2
Database Design Help Needed

dear Experts,

I have an excel sheet, the screen shot shown in picture attached(table.png) with following example structure

site name|EQX-A|SGP-A|SGP-B|JKT-A|
EQX-A | x | 1 | | 2 |
SGP-A | 1 | x | | |
SGP-B | | | x | |
JKT-A | 2 | | | x |


EQX-A, SGP-A,SGP-B JKT-A are column headers and row headers. Now i want to design an database that can store this information . keeping in mind that sites may increase in future I can not simply design a flat table with this structure.


can anyone help in this regards.
Database Design Help Needed-table.png
Thanks and best regards,
Reply With Quote
  #2 (permalink)  
Old 01-30-09, 04:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
CREATE TABLE sitexref
( site1 VARCHAR(9) NOT NULL
, site2 VARCHAR(9) NOT NULL
, PRIMARY KEY (site1,site2)
, xref INTEGER
);
INSERT INTO sitexref VALUES
('EQX-A','GSW-A',0),('EQX-A',SGB-P',0),('EQX-A',JKT-B',0),...
,('GSW-A','EQX-A',0),('GSW-A','SGB-P',0),('GSW-A',JKT-B',1),...
, ...
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-30-09, 08:27
rehanazher rehanazher is offline
Registered User
 
Join Date: Jan 2009
Posts: 2
Database Design Help Needed

dear r937,

i am using MS SQL Server as my back end and moreover am not an expert this scripting language.

can you please elobrate your design.


thanks and best regards,
Reply With Quote
  #4 (permalink)  
Old 01-30-09, 09:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
elaboration: there is one row for every cell, except the diagonal

try it:
Code:
CREATE TABLE sitexref
( site1 VARCHAR(9) NOT NULL
, site2 VARCHAR(9) NOT NULL
, PRIMARY KEY (site1,site2)
, xref INTEGER
); 
INSERT INTO sitexref VALUES ('EQX-A','GSW-A',0)
INSERT INTO sitexref VALUES ('EQX-A','SGB-P',0)
INSERT INTO sitexref VALUES ('EQX-A','JKT-B',0)
INSERT INTO sitexref VALUES ('GSW-A','EQX-A',0)
INSERT INTO sitexref VALUES ('GSW-A','SGB-P',0)
INSERT INTO sitexref VALUES ('GSW-A','JKT-B',1)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 06-22-09, 01:55
venu100 venu100 is offline
Registered User
 
Join Date: Jun 2009
Posts: 1
CREATE TABLE sitexref
( site1 VARCHAR(9) NOT NULL
, site2 VARCHAR(9) NOT NULL
, PRIMARY KEY (site1,site2)
, xref INTEGER
);
INSERT INTO sitexref VALUES ('EQX-A','GSW-A',0)
INSERT INTO sitexref VALUES ('EQX-A','SGB-P',0)
INSERT INTO sitexref VALUES ('EQX-A','JKT-B',0)
INSERT INTO sitexref VALUES ('GSW-A','EQX-A',0)
INSERT INTO sitexref VALUES ('GSW-A','SGB-P',0)
INSERT INTO sitexref VALUES ('GSW-A','JKT-B',1)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On