Tree structure in our application is still very common, such as file directory, BBS, permission settings, departmental settings. These numbers
According to the hierarchy structure of the information, and in our current relational database is difficult to clear the expression. Then you will encounter a tree in your program.
How should structural problems be dealt with?
Recently, the author through an ASP Rights Management program to easily solve a problem, and now it is sorted out readers.
First, the hierarchical data model should be transformed into a relational data model. That means how to access,sql SERVER in our
, this data structure is designed in relational databases such as Oracle.
Take an example, for example, one of the following data:
Document Management 1
|----New Document 2
|----Document Modification 3
|----Document Archive 4
| | |----VIEW archived Information 5
| | |----DELETE archive information 6
| | | |----DELETE history document 7
----Delete Official documents 8
|----System Management 9
|----User Management 10
Personnel Management 11
Administration 12
Financial Management 13
This is a very typical hierarchical structure of data, then we think about how to express it through the form of two-dimensional table? Early
It looks hard, doesn't it? But there is still a road to be drilled for careful scrutiny.
This allows you to treat all of the above permissions as a permission field, so the permission field must have an ID value. I
We're going to force another field on the relational datasheet--The Membership ID field, which indicates which level of permission this permission belongs to.
, that is, which ID value the ID value belongs to. For example, the "View archive information" Permission ID value is "5", which is subordinate to the text
File permission, the value of the Subordinate ID field should be "4". OK, if that's understandable, then I
The transformation of the relationship between the work also even if the basic completion.
Let's start by designing this relational datasheet (for example, SQL Server 7.0):
+-----------+-----------+-----------+-----------+----------+
| Field name | Field Meaning | Field type | Field Size | Field Properties |
+-----------+-----------+-----------+-----------+----------+
| Selfid | Permission ID | Int | 4 | PK |
| Powername | Permission name | Varchar | 50 | Not Null |
| Powerinfo | Permission Information | Varchar | 500 | |
| Belongid | Membership ID | Int | 4 | |
+-----------+-----------+-----------+-----------+----------+
Well, the structure is well designed so you can easily enter your test data.
Then, we will focus on how to imitate the hierarchy in the Web page to display this function of the ASP program, this is also the most critical step.
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.