Reputation: 449
How can I represent the following table in database efficiently, assuming that the number of rows and cols is more the several hundreds (I think creating database with 100 fields is not a good idea:))
I'm using Ruby on Rails/SQLite.
Upvotes: 0
Views: 1067
Reputation: 168091
Your data structure is a bipartite non-directional weighted graph. If you can use a graph database, that would be a good fit.
Upvotes: 2
Reputation: 73
What you have here is a classical de-normalisation task. And the classical approach (not knowing your read-write patterns or other needs) is to make three tables:
ID | Name
---------
1 | Gothamist
2 | GigaOm
3 | Quick Online Tips
ID | Name
----------
1 | China
2 | Kids
3 | Music
4 | Yahoo
ID1 | ID2 | Value
-----------------
1 | 1 | 0
1 | 2 | 3
...
3 | 4 | 22
Upvotes: 5
Reputation: 308753
100s of fields are most likely not normalized, but it's not always true. Normalization is your objective, not a hard and fast rule about numbers of columns.
It's hard to answer this question, because the columns and keys don't make much sense to me.
I can see a one-to-many relationship here, but that's the only suggestion that's obvious.
Upvotes: 0