Public Shared vertices() As String = {"Selandar", "ChinChin", "Jasin", "Merlimau"}
Public Shared edges(,) As Integer = {{0, 22, 16, 32}, {22, 0, 15, 26}, {16, 15, 0, 21}, {32, 26, 21, 0}}
as u can see...this is the distances that i want to keep in database..the problem is i have no idea on how to design it. could anyone please help me with this. what i got in my head is to design it like below, how can i transform this into the database?
|
|
Selandar |
Chin chin |
|
Selandar |
0 |
22 |

Munir ShaikhRank #472 · 5.3K reputationPosted Sep 26, 2007, 11:12 PM EDT
Hi,
As per the bottom table image i think it is simple to do it here i am giving you small code
If you want to store the vertices wise edges the i think the structure should be as below
Create table tblxyz
(
Id int identity(1,1) Not null primary key,
vertices varchar(50) not null,
edges int
)
Where Id is any Id which is acting as auto increment and also as primary key, so while inserting record you will only insert vertices and edges
if you want to store all the edges then it will change as below
Create table tblxyz
(
Id int identity(1,1) Not null primary key,
vertices varchar(50) not null,
edge1 int,
edge2 int,
edge3 int,
edge4 int
)
Since you have four edges for single vertices
Regards,
>>Munnamax
Munir ShaikhRank #472 · 5.3K reputationPosted Sep 26, 2007, 11:29 PM EDT
Hi again,
If you want to store comma seperated values in the table then the structure will change little bit
Create table tblxyz
(
Id int identity(1,1) Not null primary key,
vertices varchar(50) not null,
edges varchar(50)
)
Enjoy!
>>Munnamax
ana aly22 reputationPosted Oct 5, 2007, 6:23 PM EDT
hello..sorry for the late reply
i had design the database..but it mostly looks like this
id places distance
1 Bukit Bintang -> Bukit Bintang 0
2 Bukit Bintang -> China Town 0.9
3 Bukit Bintang -> Chow Kit 2.1
id became the primary key..is it possible if i design it like this?? i plan to just change tha value of this
Public Shared edges(,) As Integer = {{0, 22, 16, 32}, {22, 0, 15, 26}, {16, 15, 0, 21}, {32, 26, 21, 0}}- change each value with the primary key...referring to database using primary key
so here i want to ask...could you teach me the code on how to connect to the database and referring the primary key as i stated above? please help me sir
patrick stany2 reputationPosted Oct 29, 2007, 10:15 PM EDT
Thanks for the same. its working thanks once again.
Patrick