Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Classification, Tags and Associations. Need advice

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2009-08-12 : 09:49:36
Hello,

On a database for a education web site I need to classify the Posts and Documents according to their Subjects, Grades and Themes. Later I might need extra classification.

1) The standard way (3 base tables):

Tables Subjects, Grades and Themes.
These tables are related to Posts and Documents through tables PostsSubjects, ..., DocumentsGrades, ...

2) A more flexible approach (2 base tables):

Tables Groups and Tags.
In Groups I might insert Subject, Theme and Grade, or any other classification type, and in Tags each group's tags.


create table dbo.Groups
(
Id uniqueidentifier rowguidcol not null constraint DF_Groups_Id
default (newid()),
[Name] nvarchar(100) not null constraint U_Groups_Name unique,
constraint PK_Groups primary key clustered (Id)
)
create table dbo.Tags
(
Id uniqueidentifier rowguidcol not null constraint DF_Tags_Id
default (newid()),
GroupId uniqueidentifier not null,
[Name] nvarchar(40) not null constraint U_Tags_Name unique,
constraint PK_Tags primary key clustered (Id)
)


Then I would associate Posts and Documents to Tags using PostsTags and DocumentsTags.

I might even apply this system to Users using UsersTags to define Users interests and being able to easily get a cross reference between Users interests and Posts and Documents.

I am not sure if I should go (1) or (2).

Now what would you do?

Any comment or critic is welcome.

Thank,
Miguel
   

- Advertisement -