hi to all;
i want to make in my site the possibility for the user to make categories in the site
ex: he can add the category name"computer science" and then can add the category childs " data mining, software engineering,... "
so firstly i want to make a category table in my databasde to be able to save the category data
haw can i make this table? i mean what are the columns that should be in the table?what type of relationship should i make? and how to mahe it
sorry but i need any one to explain to me what should i do. and if anyone one know the solution please reply to me
thanks....
Selfreferencing tables ?
Code Snippet
DROPTABLE Categories
GO
CREATETABLE Categories
(
CategoryId INTNOTNULL,
ParentCategoryID INT,
DescriptionVARCHAR(4000)
)
GO
ALTERTABLE Categories
ADDCONSTRAINT PK_Categories PRIMARYKEY(CategoryId)
GO
ALTERTABLE Categories
ADDCONSTRAINT FK_Categories_Cetegories FOREIGNKEY(ParentCategoryId)
REFERENCES Categories(CategoryId)
GO
Jens K. Suessmeyer.
http://www.sqlserver2008.de
No comments:
Post a Comment