How to Store Hierarchial Data

Microsoft provides users with database solutions to store hierarchial data. Databases are the solution for storing data in this structure, because this software has the capability of storing millions of records that link to millions of other records, such as a list of customers that link to each customer's orders. To store this data, you must first make the tables, then fill those tables with the data you want to store.

Instructions

    • 1

      Open SQL Server Management Studio on your database server and log in to the database in which you want to store the data.

    • 2

      Click the database name in the left panel. A list of components that make up the database is shown such as stored procedures, tables and users. Right-click the "Tables" icon and select "New Table." A window opens where you create a new table.

    • 3

      Type the column information in each section. Continue adding new columns until you have each section of information for your table. Since this is a hierarchical design, you place only one type of data in the first table. For instance, add "name, address and phone number" for a customer table that links to an orders table.

    • 4

      Click "Save" to save the table. Type a name for the table in the opened dialog window. After you create each table, you must input data. Click the "Query" icon in the toolbar to open a window in which you set up your "insert" query.

    • 5

      Type the query to insert the data. Because an order requires a customer, you insert the main content, then add the secondary content. The following code shows you how to insert a customer and then insert a customer order:

      insert into customer (name, address) values ('joe johnson', '111 street')
      insert into orders (customer, product) values ('joe johnson', 'widgets')

    • 6

      Click "Run" to execute the query and insert the hierarchical data. You must use the query for each record you want to insert.

Related Searches:

References

Comments

Related Ads

Featured