0

I am doing an email application which will allow multiple attachments and emails will be send on schaduled date. I have some desgining issues here. Please guide me with your expereienced knowledge.

Email will be stored in db table but attachments will be stored in a folder on server. User will upload files first later his email will be stored in db. I have messages and attachments tables. But there are some cases which system should be able to handle.

  1. How I should store attachments of emails of different users (in one folder or in multiple folders) ?
  2. How attachment naming should be manged, more then one attachments (by one or different users) can have same name ?
  3. User can upload files but later can leave composing message, how system will handle such atachments ?
  4. What will be best time to save email message in db table on user button (save or draf) press or compose page request ? If you suggest on page request then how to handle messages that were not successfully finished ?

Plase guide if I am missing any thing else.

I will be more thankful for your guidance, time and sincere advice.

user576510
  • 5,777
  • 20
  • 81
  • 144

1 Answers1

2

You have a couple of choices on storage of drafts:

  1. Separate draft table (or set of tables)
  2. Mark message as draft

If drafts can be auto-deleted after some time, the first is easier. It may also be easier to handle the programming to keep it isolated, but flagging the email message in the database as draft works, as well.

When to save? I would save both drafts and ready to send emails, as there is too much risk of losing them if you don't persist them and persistence to a common location is nicer.

Multiple files with same name? Either you physically separate the user's items into different directories or you change the name of the file and store the name it should have as an attachment and have it "renamed" back when the email is sent.

How to handle attachments of emails never properly composed? that is a business decision, not a technical one. Whatever you choose, the user should know the rules.

Gregory A Beamer
  • 16,870
  • 3
  • 25
  • 32
  • Thanks @Gregory, 1. Any benefit of sepratign draft table then putting a column in same table ? Regarding files saving even user can have multiple files with same name with different emails ? Business rule is we dont need attachments that do not have emails with them. I dont understand how to handle it. thanks once again. please reply. – user576510 Jul 14 '11 at 14:49
  • The benefit of a draft table or tables is being able to clean "stuff" out without hitting the main table. As for the attachments without emails issue, store the attachment with a date and a key that can be null (no email) or have an ID to an email (this may just be a table with a pointer to a file rather than actually storing the file in the database). After a certain time (X days? X months? 1 year?), delete the entries that do not have emails. Business will have to determine the clean up period. – Gregory A Beamer Jul 19 '11 at 14:03