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 4085882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:38:45+00:00 2026-05-20T18:38:45+00:00

I have to add some functionality to a system that is already a mess

  • 0

I have to add some functionality to a system that is already a mess and I don’t want to make things worse. This shop places very little value on proper design but I do so looking for a compromise.

They want to add the ability to add file attachments to various entities in the database but the files would be stored on a file system. The entities they’d like to attach files (one to many) are, and they want every attachment accounted for in the database (pointer filename with root_mount_point a dynamic parameter. How I will keep it in sync is my next nightmare. But I’m torn on what to use for a “many” table for the one to many attachments for a Client, Account, Vendor, or Invoice.

create table client {
  client_id      char(11)   not null,
  ...
}

create table account {
  client_id      char(11)   not null,
  account_number char(22)   not null,
  ...
}

create table vendor {
  client_id      char(11)   not null,
  account_number char(22)   not null,
  vendor_number  char(15)   not null,
    ...
}

create table invoice {
  client_id      char(11)   not null,
  account_number char(22)   not null,
  vendor_number  char(15)   not null,
  invoice_number char(22)   not null,
  invoice_date   datetime   not null (yes this is part of PK)
  ...
}

Each of these is one to many as you work your way down.

I’m thinking of doing something like this for a “file_attachment” table which can be a many table for either of the four entities, depending on which columns are null. If Invoice cols are null the attachment is to vendor, etc.

create table NEW_ENTITY_ATTACHMENT {
   attach_id           char(11)   not null   (dummy key, but keeping their char 11 standard),
   attach_status_cd    char(1)    not null,   ( "A"ctive or "D"eleted ) ,etc.
   attach_status_date  datetime   not null,  (they want complete history, soft deletes, and restores)
   client_id           char(11)   not null,
   account_number      char(22),
   vendor_number       char(15),
   invoice_number      char(22),
   invoice_date        datetime,
   attachment_filename char(blah blah),
   ..
   .. 
   blah
}

So the first three columns are required, client_id required and the account, vendor, invoice optional depending on which level the attachment is stored.

Am I way off on my thinking here, should there be a many table for EACH entity (e.g. Client Attachment, Account Attachment, Vendor Attachment, Invoice Attachment? If this is the answer they don’t want to hear it anyway so I’m screwed.

I don’t ask many questions but GREATLY appreciate any suggestions. Keep in mind this client just wants it done they consider this a one to two day project including data model, GUI, and backend. It’s Sybase ASE15 if it matters.

Thanks in advance.
R

  • 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-20T18:38:46+00:00Added an answer on May 20, 2026 at 6:38 pm

    Given the key structures of the other tables, putting all your attachments in one table makes sense. For example, you’ll be able to query all the attachments that belong to a client (at all levels) by selecting on just client_id, and attachments that belong to a client (at just that level) by selecting on client_id and account_number IS NULL.

    The one problem I see is the key for your new table:
    Using a date as part of a key (attach_status_date) makes me uncomfortable (and it obviously makes you uncomfortable too based on your comment about invoice_date).

    Is the attach_id going to be unique? If not, then even with attach_status_date as part of your key you may not get a unique key. If it is going to be unique (A GUID maybe?) then having attach_status_date as part of the key doesn’t seem necessary especially since it doesn’t look like you will be linking to this field. Maybe it should just be indexed?

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

Sidebar

Related Questions

I have this web application that has grown to an unmanageable mess. I want
We have subclassed the Silverlight Application class to add some additional functionality and then
I have a question about some functionality I'm trying to add to my jQuery
I have a search page and want to add some filters to it, my
I am attempting to add some entities that I have created. When I try
I'm enhancing an open source control to add some functionality that I need, and
I have Java desktop application that works with CSV files. And i want add
I have a system that performs operations on lots of Things , these can
I have a number of UserControls that I want to each have some basic
I have to add some enum options to a database table. The problem being,

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.