views:

90

answers:

2

I'm building simple application for myself in JSP which stores URL for me and finds it based on tags. For which i want to design a database. I'm limited with my knowledge of SQL. But still i want to learn by doing.

I want to create database that stores tags for the URL and the URL itself. The URL could be text(50) or more in a table column (or any other suggestion ?). After storing the URL I want to associate a tag ( which is again text(50) ?). Do i need to separate the tags and URL from table? If so how should I associate URL and tags to each other in any way?

There could be duplicate of my question, but I'm concerned with my database design (as explained above) and SQL syntax. So please suggest me how to proceed.

Am I proceeding the right way? Or do I need to think of a better database design? Any suggestions about database design?

+4  A: 

This seems like a candidate for a many to many relationship, assume that a URL can have more than one tag. That way, you would have a tags table, a url table and a tags-url correlation table.

As for the length of the URL, it depends, the url for this question is 76 characters. You need to see what your longest url may be.

phsr
Any suggestions for books/tutorials, URL for more information on this ?
Stark
Not off the top of my head, but after a quick search, I found http://www.tomjewett.com/dbdesign/dbdesign.php . Seems looks like a decent site
phsr
Thanks for the link.
Stark
+2  A: 

There is a DB schema called Tagschema: http://forge.mysql.com/wiki/TagSchema

powtac
i'm new to this schema. I've shallow knowledge of SQL. Can you guide me any further for working with schema ? URL/Book/Tutorial suggestion is much appreciable.
Stark
Hi Stark, you can visit the service I started at http://cakeapp.com. Its a DB schema community with visual SQL editor and live creation of an MVC out of the schema. There you can check how n:m relations are used. They are called "HABTM" connection on cakeapp.com.
powtac
Thanks for answer powtac.
Stark