| |
|
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.
|
 |

01-30-09, 00:44
|
|
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 | | |
S GP-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.

Thanks and best regards,
|
|

01-30-09, 04:16
|
|
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),...
, ...
|
|

01-30-09, 08:27
|
|
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,
|
|

01-30-09, 09:54
|
|
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)
|
|

06-22-09, 01:55
|
|
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)
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|