Unlimited classification (non-recursive algorithm/Stored Procedure edition/GUID primary key) complete database example _ (1) Table Structure

Source: Internet
Author: User

Unlimited classification is an old topic. There are many solutions on the Internet, which can be divided into two genres, one using recursion, one method is to use non-recursion (of course, other auxiliary methods are required to determine the node level), but the core table structure is similar, there are three key fields (id Primary Key, parentid parent class ID, classname-theoretically, if recursion is used, the three fields are sufficient.) The complete table structure is as follows:

Create Table [DBO]. [t_class] (
[F_id] [uniqueidentifier] not null constraint [df_t_class_f_id] default (newid ()),
[F_classname] [nvarchar] (256) Collate chinese_prc_ci_as null constraint [df_f_classtest_f_classname] default (''),
[F_shortname] [nvarchar] (50) Collate chinese_prc_ci_as null,
[F_parentid] [uniqueidentifier] Null constraint [df_t_class_f_parentid] default (newid ()),
[F_depth] [int] Null constraint [df_f_classtest_f_depth] default (0 )),
[F_rootid] [int] Null constraint [df_f_classtest_f_rootid] default (0 )),
[F_orders] [int] Null constraint [df_f_classtest_f_orders] default (0 )),
[F_parentidstr] [nvarchar] (300) Collate chinese_prc_ci_as null constraint [df_f_classtest_f_parentidstr] default (''),
[F_parentnamestr] [nvarchar] (300) Collate chinese_prc_ci_as null constraint [df_f_classtest_f_parentnamestr] default (''),
[F_readme] [nvarchar] (250) Collate chinese_prc_ci_as null constraint [df_f_classtest_f_readme] default (''),
[F_addtime] [datetime] Null constraint [df_f_class_f_addtime] default (getdate ()),
[F_type] [nvarchar] (50) Collate chinese_prc_ci_as null,
[F_maxpage] [int] Null constraint [df_t_class_f_maxpage] default (0 )),
[F_no] [nvarchar] (50) Collate chinese_prc_ci_as null,
[F_isshow] [tinyint] Null constraint [df_t_class_f_isshow] default (0 )),
[F_autoid] [int] identity (1, 1) not null,
Constraint [pk_t_class] primary key clustered
(
[F_id] ASC
) With (ignore_dup_key = OFF) on [primary]
) On [primary]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.