|
Hello all,
I've been using SQL Server Express in my project which has some tables that are related to each other.
I'm coding the resource called as "Tag Clouds".
I think you already know it.
How have I implemented that?
Firstly sorry by posting a large comment here!
but that problem is not easy to tell someone
Let me present "Tag" table...
oa_tag
Id: int, not null, primary key
TagName: varchar(50)
Frequency: int
it will contain all application's tags. I decided to use "Frequency" column just to mapping purposes. This one will contain how many tags can be found related with other tables
Secondly,
I have other three tables...they're where I can mark with tags found in "oa_tag" table.
they are as follows:
- oa_article
- oa_poll
- oa_blog_entry
naturally each one has a table related to do the relationship with the oa_tag.
they are as follows:
- oa_article_tag
columns:
=> ArtilceId
=> TagId
- oa_poll_tag
columns:
=> PollId
=> TagId
- oa_blog_entry_tag
columns:
=> BlogEntryId
=> TagId
as you can see..there are "many-to-many" relationship between those tables.
Let's continue
for instance, if I have the following tags (records) in oa_tag table.
oa_tag table data
ID | TagName
127 | microsoft
128 | windows
129 | linux
130 | freebsd
and...
oa_poll_tag table data
PollId | TagId
18 | 127
18 | 128
18 | 129
18 | 130
and...
oa_blog_entry_tag table data
BlogEntryId | TagId
10 | 127
10 | 128
10 | 129
now..i'd like to know how many for each tag that I have!
So, according to its result in the SQL Server Management Studio Express..I coded a SQL query that give me this information very well...
actually I need 3...one for each table...and one another for all tables...
the number 1. give me the frequency of the tags only related to "oa_article"
2. give me the frequency of the tags only related to "oa_blog_entry"
3. give me the frequency of the tags only related to "oa_poll"
4. give me the frequency of the tags for all ones
what's happening?
when one tag has more than one record in those tables such as "oa_blog_entry_tag", "oa_article_tag" and "oa_poll_tag"...Hibernate erases the correct frequency found in database...
according to data presented before, on the SQL Server Management Studio Express, the results are:
tags related to poll
TagId | TagName | Frequency
127 | microsoft | 1
128 | windows | 1
129 | linux | 1
130 | freebsd | 1
tags related to article
TagId | TagName | Frequency
0 | 0 | 0
(there are no records in this table)
tags related to blog_entry
TagId | TagName | Frequency
127 | microsoft | 1
128 | windows | 1
129 | linux | 1
but when I use NHibernate in order to get the same results above...doesn't happen the same...
see the results:
tags related to poll
TagId | TagName | Frequency
127 | microsoft | 0
128 | windows | 0
129 | linux | 0
130 | freebsd | 1
tags related to article
TagId | TagName | Frequency
0 | 0 | 0
tags related to blog_entry
TagId | TagName | Frequency
127 | microsoft | 0
128 | windows | 0
129 | linux | 0
of course...that results would be in a collection as
IList<Tag> myCollection;
that's is populated via NHibernate
as you could see..when it's found more than one record...Nhibernate erases the Frequency of column...in this case..just freebsd is correct...if I insert one record relating "freebsd" with any article or blog..Nhibernate will erase s too..
what hell is happening?
would be it a bug?
I hope that anyone can understand me. (my English is not so good)
Thanks in advantage!
|