Simple entity relationship redundancy error

260 views Asked by At

I am using ER Assistant to create my first entity relationship diagram.

I have created an entity called Users which contains the following attributes

UserID (identity 1,1) PK 

UserName  (varchar, 50)

I have created a second entity called Logs, its attributes are

LogID (Identity 1,1) PK

LogEntry (varchar, 256)

UserID FK

I have assigned it assertions as follows,

  • A user can create many logs
  • A log must be created by only one user

The relationship is defined as one user to many logs with user being mandatory and the logs are optional

The error I am getting is:

"The 'UserID' attribute in the 'Logs' entity type is redundant with the 'Creates' relationship. Because 'UserID' is the primary key of 'Users' it should not be an attribute of 'logs'.

So my question is, if I do not place the UserID as a foreign key in the Logs table, how do i properly associate the two? I thought I had a decent understanding of how this works but this is definitely not making sense to me at the moment. I am unsure if this is an error in the validity checking or I am actually doing this incorrectly.

1

There are 1 answers

5
Anand On BEST ANSWER

Since the UserID is not a property of the Logs table (consider a Log being created by a User as well as the System, hypothetically), good design dictates that you separate out the relationship into a 3rd table:

UserLogs
--------
UserID
LogID

This way if a log is created by the System, you could create another table:

SystemLogs
----------
SystemID
LogID

And use the same entity Logs for both relations