Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3235730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:32:24+00:00 2026-05-17T17:32:24+00:00

I have a project that I am working on and I can’t figure out

  • 0

I have a project that I am working on and I can’t figure out which would be a “better” table relationship schema.

The scope of the area in question are:

  • User uploads documents (become the owner/author)

  • User can share document with other users (set share rights)

  • Any user who has access to document can checkout the document (exclusive lock)

My original schema looks like this:

alt text

Benefits are:

  • only one user can be author. (authorid)

  • Rights table contain only “sharerights” (Read, Write)

  • User has easy distinction as to which files they “own” (authorid) vs sharedfiles (sharedfiles table). (this one is a weak benefit, I know)

After thinking things through I thought that this might be a better schema:

alt text

Benefits are:

  • All document associations are located in one location (UserFiles)

  • Future ability to allow multiple authors/owner of a single document

Rights table would now have Read, Write, and Owner. As soon as a document was uploaded by a user, an automatic association would be made to a new document and the user would be given “owner” rights.

This led me to the final schema:

alt text

Benefits are:

  • If a user file association is removed (removed share) and that user had a lock on the file (Checked out), then that exclusive lock would be automatically removed.

The only problem with this last model is that I plan to add “special” user for each department so that a user could share a document to an entire department. So I am not sure if I want to associate the share association to the checkoutID (if that makes sense). The query for the users files would look like “select all files where userfiles.userid = me.userid || (userfiles.id == SpecialDepID && me.depid == SpecialDepID)” (major pseudo code)

It has been a long time since I have done database schemas and this one design decision is really racking my brain. It is really bugging me as to which design would be “better” and by better I mean better design principles, better decision based off of previous experience, allows for easier “growth” in the design, etc. Please let me know your thoughts!

FINAL SOLUTION

With the help from Michael Madsen the final solution looks like:

alt text

There will be a trigger on UserFiles for delete which will determine if a lock should be deleted when a relationship is removed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:32:25+00:00Added an answer on May 17, 2026 at 5:32 pm

    If it were only those three options, I’d go with the second one and place a trigger on deletion from UserFiles to handle the issue you’re trying to handle with the third design.

    You’ve already provided good reasons for choosing that one over the first one, so I’m not going to repeat that.

    The third design isn’t good, though – it’s not straightforward to see if a file is locked; you have to see if a sharedFileID exists where the fileID matches the one you’re after, meaning multiple records per table. It’s also not nice that you’re missing a primary key on CheckedOutFiles, so that also counts against that one.

    However, we can of course fix those problems. If you were to use FileID as the primary key in CheckedOutFiles, you would be able to avoid those two issues – you have a meaningful primary key, and you can easily check if a given file is locked.

    Of course, even if you do that, you still have the problem of the “special” user. A simple way you could use to handle that is by storing the actual user as part of your checkout table – the sharedFileID references the department user, while you still have a reference to the actual user to verify that you’re dealing with the right user.

    With those changes, the third design seems best – you only reserve space for lock information for the files that are actually locked.

    TL;DR: Third design, but with fileID as the PK in CheckedOutFiles, and a specific UserID as part of CheckedOutFiles to handle “meta”-users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on asp.net (vb, maybe that can change something) I have a project
The project I am working on has a rich text box that can have
I have a large-ish project that I'm working on which uses git as the
I have a WiX project that I am working on which includes a Windows
We have a simple project that uses JsonValueProviderFactory which we have working on a
I have an AIR project that I was working on Flash Builder 4.5 which
I have a project that I am working on in django. There are a
Yes I have a project that I'm working on in NetBeans 7.1 and I
I have a working project that Im amending, it crashes after trying to use
I have a django project that I have been working on as a solo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.