MYSQL/Rails Database design for linked objects best practice?

I have 2 ruby/mysql database structure questions:

A – The set-up

I have 2 objects, (e.g., employees and documents), in this example, I would like to allow some employees to access other employee’s documents. The access should also have permission levels (view, edit, full).

Employee:

class Employee < ActiveRecord::Base
    has_many :documents, :dependent => :delete_all
end

and Document:

class Document < ActiveRecord::Base
    belongs_to :employee
end

B – The options
I am trying to decide which is the better database/best practice for how to do this. I see two options:

Option 1) Employee could have linked documents.
In this case, the document owner is adding access to the other employee (i.e. the one employee is editing the other employee)

Employee has many linked documents. (simple one-to-many relationship edited by the document owner) For data structure, I could follow this example:
Rails Many to Many with Extra Column

In the documents controller, index, I would select all documents, I would do something simple:
Select employee.documents, and employee.linked_documents, two datasets, loaded at the time the employee is.

Option 2) Documents could have linked employees.
In this case, the document is edited by its owner, granting access to other people. The Document would have many linked users (simple one-to-many relationship edited by the document owner).
Like above the data structure would be like the linked article.

The select statements are not as clean. The initial select can be the same, select employee.documents, but the other would be some sort of select documents.where(document.linked_user = current user).

C – My efforts
I am leaning towards option 2 because the document is edited by the employee, rather than employees editing another employee.

In my document controller, show, I have some logic to ensure the document is owned by the employee:
if document.owner != current user redirect to no access. I imagine I would need to refactor this to a document level property. if doccument.accessallowed == false redirect to no access. It seems that adding this to the document would reduce cluttering the controller with “if this” or “if that”s.

D – The Ask:

  1. Which is better, option 1, or option 2?
  2. Is the document level access property the right solution for either option?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật