Issues with table design

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 704 Views - Last Post: 24 May 2013 - 01:10 PM Rate Topic: -----

#16 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 115
  • View blog
  • Posts: 1,332
  • Joined: 14-January 10

Re: Issues with table design

Posted 15 May 2013 - 04:35 PM

Does this look correct?

Posted Image
Was This Post Helpful? 0
  • +
  • -

#17 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 782
  • View blog
  • Posts: 1,663
  • Joined: 30-January 09

Re: Issues with table design

Posted 15 May 2013 - 06:03 PM

That diagram looks good, and meets 3NF.
Was This Post Helpful? 0
  • +
  • -

#18 RandomlyKnighted  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 115
  • View blog
  • Posts: 1,332
  • Joined: 14-January 10

Re: Issues with table design

Posted 15 May 2013 - 06:14 PM

Awesome! Thanks for your help!
Was This Post Helpful? 0
  • +
  • -

#19 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: Issues with table design

Posted 18 May 2013 - 11:56 AM

View PostRandomlyKnighted, on 10 May 2013 - 07:10 PM, said:

Alright, I just have 2 questions. With the removal of the Parent Company table, you made the Company table have a parentID and you made it have a foreign key to the companyID in the same table. Did I read that right?


This is fairly common and is called a "self join". Another example might be Employee with ID, ManagerID, Name, etc etc. The ManagerID would be an ID from a different Employee record.

Quote

Keep in mind that you will need to make parentID nullable for the purposes of root nodes.
If you don't want to do that, another approach is to simply set the root nodes to reference themselves, i. e. have the same key value in both the primary and foreign key fields. For example, using the Manager/Employee context, Bill Gates's boss is Bill Gates.
Was This Post Helpful? 0
  • +
  • -

#20 James1992  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 30-October 12

Re: Issues with table design

Posted 24 May 2013 - 01:10 PM

People have probably said this all before. If a user has access to a document but they may want another person to be able to view it, then you could just add another attribute within the document users and have a unary relationship. Or just have a table about users, a table about documents and a table with the userID and documentID.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2