Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Hierarchical database model
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Examples of hierarchical data represented as relational tables == An organization could store employee information in a [[table (database)|table]] that contains attributes/columns such as employee number, first name, last name, and department number. The organization provides each employee with computer hardware as needed, but computer equipment may only be used by the employee to which it is assigned. The organization could store the computer hardware information in a separate table that includes each part's serial number, type, and the employee that uses it. The tables might look like this: {| |- | {| class="wikitable" |+ <code>employee</code> table ! EmpNo !! First Name !! Last Name !! Dept. Num |- | 100 || Almukhtar || Khan || 10-L |- | 101 || Gaurav || Soni|| 10-L |- | 102 || Siddhartha || Soni || 20-B |- | 103 || Siddhant || Soni || 20-B |} | {| class="wikitable" |+ <code>computer</code> table ! Serial Num !! Type !! User EmpNo |- | 3009734-4 || Computer || 100 |- | 3-23-283742 || Monitor || 100 |- | 2-22-723423 || Monitor || 100 |- | 232342 || Printer || 100 |} |} In this model, the <code>employee</code> data table represents the "parent" part of the hierarchy, while the <code>computer</code> table represents the "child" part of the hierarchy. In contrast to tree structures usually found in computer software algorithms, in this model the children point to the parents. As shown, each employee may possess several pieces of computer equipment, but each individual piece of computer equipment may have only one employee owner. Consider the following structure: {| class="wikitable" |- ! EmpNo !! Designation !! ReportsTo |- | 10 || Director || |- | 20 || Senior Manager || 10 |- | 30 || Typist || 20 |- | 40 || Programmer || 20 |} In this, the "child" is the same type as the "parent". The hierarchy stating EmpNo 10 is boss of 20, and 30 and 40 each report to 20 is represented by the "ReportsTo" column. In Relational database terms, the ReportsTo column is a [[foreign key]] referencing the EmpNo column. If the "child" data type were different, it would be in a different table, but there would still be a foreign key referencing the EmpNo column of the employees table. This simple model is commonly known as the adjacency list model and was introduced by Dr. [[Edgar F. Codd]] after initial criticisms surfaced that the relational model could not model hierarchical data.{{citation needed|date=May 2018}} However, the model is only a special case of a general [[adjacency list]] for a graph.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)