Introduction This tutorial will show you how to store hierarchical menu data in a single database table and how to retrieve and transform that data for display in Microsoft's Menu. Each step is explained and illustrated so that you can quickly extrapolate from this article to build your web application's menu. Note: This tutorial requires Visual Studio 2005 and SQL Server. Step 1 - Create and Fill a Database Self Join Table Our menu's table will use a self-join relationship which is the simplest method of storing hierarchical data. Child rows will use ParentID to establish a relationship with the MenuID of a parent row as shown below. Figure 1 - Table Overview Let us start by creating a database called MenuDb and a Table called Menu. This can be done by running the following script from Microsoft's Query Analyzer. Listing 1 - Database Script CREATE DATABASE MenuDb GO USE MenuDb GO CREATE TABLE [Menu]...
Get into The World of Information