Direct Question:
What are best practices for design of database tables for storing urls configured on a page.
Our use case:
We had a design discussion and were unable to conclude on a what is the correct design. We are writing a page with URLs embedded in a table. So the page looks like
....content(some text)...
a |b |c |d
text |url |url |url
text |url |url |url
text |url |url |url
....content(some text)...
The idea is to make these urls configured in database so that url changes does not need a deployment every time it url changes.
EDIT> a,b,c,d
are table headers. While the content under section a
will be a normal text the content under b,c,d
will be hyperlinks.
Given all this what should the table design for this structure. We considered two schemas:
(a,b(url),c(url),d(url)) #dependent on table design. advantage: written code would
#be very simple and would not be dependent on the number
#of entries in the table.(a simple for loop would
#suffice for presentation logic). Disadvantage: if table
#changes in future, this table is doomed.
#EDIT>a,b,c,d are place holders to represent that content
#represent the headers of table.
(id, url) #advantage: Generic enough to encompass any url.
#disadvantage: This would require presentation layer changes in
#case of new addition of new row.
#EDIT>id is just a number to identify this url and would be used to
#refer while identifying this from presentation layer.
We were unable to conclude which one of this is better to go with as each have its own tradeoff(until we have missed something). Or none of this is good.
We are using a NoSql Store and Jsp to write the frontend(presentation) logic.
EDIT> The following can be the type of changes that can happen to the table:
- addition of a new row(frequent).
- removal of an existing row(frequent).
- Order of columns can change(but rare).
- Number of columns change(very rare, do not think ever happened but can happen).
- Change of underlying URL(inherently supported in both designs, so not important).
The main concern here is maintenance overhead(both in presentation and back-end perspective ) that will be caused by any one of the design considered.
EDIT2>
So this project is only about writing front end for the already existing services. We do not have to deal much with so called application state. But on a certain web-page there were a few URLs(embedded in the table which I mentioned) and business requirement was not to deploy (this piece of code) every time someone has pus a change request(like change of existing url which is the most frequent type of change). So all the information on URLs is to be moved to a database and is to be queried on page load(or may be pre-load so that we do not screw the performance of page) from the webpage. Now this discussion was about designing a appropriate table for this use.