Post subject: [Help] [VB.Net/C#] Creating an Image Database program
Editor
Joined: 3/31/2010
Posts: 1466
Location: Not playing Puyo Tetris
I have a lot of images on my computer. What I wanted to do is tag the images and then have a program that will allow me to filter through the tags, and choose images based on the tags I choose. I would be using a List Check Box for the tag(s) I want. But, I can't seem to figure out a clean method that will allow me to setup a list of tags and what file(s) they apply to inside my program. I wanted a database but the Field for the tags would be awkward to parse, I think. How do sites that use tags for images, accomplish this?
When TAS does Quake 1, SDA will declare war. The Prince doth arrive he doth please.
Joined: 1/26/2009
Posts: 558
Location: Canada - Québec
If an image can have several tags, the easy way around is to use a table that map the path for the image and a tag(2 column). For each tags, you simply add one more entry. All the image and tags can be mixed together, so you simply use the WHERE clause of your favorite DBMS to select the list of tags. Later, if you want to modify the list of tags for an image, this should be a lot easier. If you dislike adding that single additionnal table, it's possible to use a NoSQL database such as MongoDB, but I wouldn't recommand trying it before getting more confortable with SQL-like database at first.
Joined: 7/2/2007
Posts: 3960
You could set up an actual database for this, but the use case is so simple that it's probably easier to just have a single file, that'd look something like this:
tag1, tag2, tag3, tag4, ...
path/to/file1: tag1, tag2, ...
path/to/file2: tag3, tag4, ...
Your program would load the file, read the first line to get the list of valid tags, then read the following lines to learn which files have which associated tags. In the program you'd build a map of tags to lists of files that have those tags. The user selects the tags they want to filter by, you extract the lists, and then you go through and find all files that are in all of the lists; that's your result. Alternately, if your language supports a Set datatype, then the tags should map to sets of files instead of lists, and you just intersect all the sets to get the set of files that have all tags. This is a very simple and limited approach to the problem. If you want to do something more complicated with a GUI and all that, then you certainly can. I'm just trying to point out that the underlying functionality is not that complicated and certainly doesn't require a full-blown database.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Editor
Joined: 3/31/2010
Posts: 1466
Location: Not playing Puyo Tetris
http://www.ehow.com/how_10030358_use-data-sets-vbnet.html Looks like Data sets is the winner. Data sets behave like a database but doesn't require overly complicated SQL connections.
When TAS does Quake 1, SDA will declare war. The Prince doth arrive he doth please.
Demon_Lord
He/Him
Joined: 2/20/2011
Posts: 80
Location: Chicoutimi, Qc, Canada