<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1046281" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1046281</link>
    <description></description>
    <language>en</language>
          <item>
    <title>I&#039;m not sure I understand</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-insert-hierarchical-data-respective-id#comment-1247608</link>
    <description> &lt;p&gt;I&#039;m not sure I understand what you are asking?&lt;/p&gt;
&lt;p&gt;If you are attempting to store companies, and their related users, I&#039;d go with a simple parent/child relationship.   &lt;/p&gt;
&lt;p&gt;Consider:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;create sequence seq_companies;&lt;br /&gt;create table companies (&lt;br /&gt;&amp;nbsp; company_id int not null primary key default nextval(&amp;#039;seq_companies&amp;#039;),&lt;br /&gt;&amp;nbsp; company_name&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;create sequence seq_company_users;&lt;br /&gt;create table company_users (&lt;br /&gt;&amp;nbsp; company_id int not null,&lt;br /&gt;&amp;nbsp; user_id int not null primary key default nextval(&amp;#039;seq_users&amp;#039;),&lt;br /&gt;&amp;nbsp; user_name varchar(100),&lt;br /&gt;&amp;nbsp; CONSTRAINT &amp;quot;company_to_users&amp;quot; FOREIGN KEY (&amp;quot;company_id&amp;quot;) references companies (&amp;quot;company_id&amp;quot;) ON DELETE CASCADE ON UPDATE CASCADE&lt;br /&gt;);&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Insert a company into the companies table.&lt;br /&gt;
Insert users into the company_users table.  When inserting a user, insert their company_id as well.&lt;/p&gt;
&lt;p&gt;This would only provide one level of &#039;heirarchy&#039; however - there are companies, and then there are users.  If you want to get a &#039;deeper&#039; structure, you&#039;ll need to look at &quot;Nested Sets&quot;, or consider storing your heirarchical data in a different type of store than RDBMS, such as LDAP.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;
Shaggy.&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Mar 2010 21:40:18 +0000</pubDate>
 <dc:creator>Shaggy</dc:creator>
 <guid isPermaLink="false">comment 1247608 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
