4 Replies - 1778 Views - Last Post: 24 October 2012 - 02:44 AM Rate Topic: -----

#1 toad87  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 188
  • Joined: 21-May 12

Is this a recursive relationship?

Posted 19 October 2012 - 12:28 AM

Hello. I am creating an ER Diagram for a class project.

It's basically a company that owns apartment complexes. Each complex has one manager. But here's the fun part! A manager is also a tenant of that complex.

For Tenant my attributes are:
FirstName
LastName
DOB
LeaseNo
PhoneNo
DLNumber
SSNumber

For ComplexManager:
FirstName
LastName
EmployeeNo
AptNo

These two Entities are one and the same...but don't really have the same attributes...so are they really recursive?
I don't know how I should diagram this.

P.S. I have a Lease entity that specifies the AptNo and Rent for the tenant and a Employee entity specifies the salaray,position, etc for the ComplexManager.

Any help would be appreciated.

Thanks in advanced.

Toad.

Is This A Good Question/Topic? 0
  • +

Replies To: Is this a recursive relationship?

#2 Darky88  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 16-October 12

Re: Is this a recursive relationship?

Posted 19 October 2012 - 04:57 AM

Yes it is recursive relationship...
First of all Include
Tenant ID and Complex Manager ID...
This will be your Primary Keys
For e.g:
if two tenants have same ID,First Name and Last Name but live in two different Complex can be distinguished via Complex Manager ID.


Complex Manager ID would be a Foreign Key...
Was This Post Helpful? 0
  • +
  • -

#3 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,470
  • Joined: 07-April 08

Re: Is this a recursive relationship?

Posted 19 October 2012 - 08:05 AM

So to get rid of this issue you would strip out all of the information from the ComplexManager table that also exists in the Tenant table. You would then give the Tenant table an auto-increment field which will be the ID for that tenant. Then within the ComplexManager table you would have a FK relationship (This can also be your PK if one manager can only manage one complex) to the ID in the Tenant table. I would also move AptNo from the ComplexManager table to the Tenant table because it describes the Tenant not the Manager

For Tenant my attributes are:
TenantID
FirstName
LastName
DOB
LeaseNo
PhoneNo
DLNumber
SSNumber
AptNo

For ComplexManager:
TenantID (FK,PK)
EmployeeNo
Was This Post Helpful? 0
  • +
  • -

#4 toad87  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 188
  • Joined: 21-May 12

Re: Is this a recursive relationship?

Posted 19 October 2012 - 10:53 AM

Hey firefly, thanks for the help. Thanks to Darky too.

But I'm still having a problem.

I created the ComplexManager Table with EmployeeId and TenantId. But the problem is I also have an Employee Table.

The Employee Table and the Tenant table have some of the same data. Specifically, FName, LName, SSNumber, and DOB.

So if I had a ComplexManager Table with EmployeeId and Tenant Id, they would link to two tables with the same type of data...

I think that would be bad because if the person got married and changed her last name under the Employee table and forgot to change her last name on Tenant Table...we would have I think what is called an...anomolie? Is that the right weird?

I have the Employee Table because of other types of workers that work for the company.

If I get rid of the ComplexManager Table completely and just put an EmployeeId attribute in the Tenant Table...it would still have the same effect, right? There would still be two tables (Tenant and Employee) that have the same info...
Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Is this a recursive relationship?

Posted 24 October 2012 - 02:44 AM

so my suggestion is remove the table ComplexManager
just create like this
Tenant

TenantID
FirstName
LastName
DOB
LeaseNo
PhoneNo
DLNumber
SSNumber
IS_Manager
EmployeeNo
AptNo


if you want to seperate it for complex manger createa a filtered view for that like this

Create View ComplexManager
as
Select TenantID,
FirstName,
LastName,
DOB,
LeaseNo,
PhoneNo,
DLNumber,
SSNumber,
EmployeeNo,
AptNo
from dbo.Tenant  
where Is_Manager =1



later you can use it your db anywhere as a separate object complexmanager
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1