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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:57:30+00:00 2026-05-25T23:57:30+00:00

Quick question: We want to be able to store a user avatar image for

  • 0

Quick question:

We want to be able to store a user avatar image for our chat users, so that everyone who is logged into the application can see that image in regards to the user. This is a C# winforms chat IRC application, which authenticates against a DB for the user, before handling the IRC commands.

Essentially, we want to be able to query the image for the user from a BLOB in the database, and assign that image to a control. This will allow us to have everyone upload an avatar (if they wish), and everyone see that as well as their username in the user cards we are creating.

Is it best to store those images in the sql database? I figure it wouldn’t be an issue considering that they would be relatively small images (less than 64k), and are only pulled and transmitted when a user is requested from the DB.

Question is, is it the best method to do that? And, how could we do that if we were using the mySqlConnector. Is it as simple as

Select * from Images Where Username='BLAH'

and then just streaming that data as an image stream to the picture box in C#?

  • 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-25T23:57:31+00:00Added an answer on May 25, 2026 at 11:57 pm

    Best practise

    1- Never do select *; that’s an anti-pattern.
    select * selects way too much, only select the field(s) that you need.

    SELECT field1 [,field2][,field....] FROM images WHERE 
    

    2- username cannot be a field in table images; that violates 1NF.
    Put users in a separate table:

    table user
    
    id unsigned integer not null primary key auto_increment,  
    -- id is a redundant key to speed up joins. 
    name varchar(255),
    other_fields.....,
    unique index ui_name (name)   -- << make sure user.name is unique.
    
    table image
    
    id unsigned integer not null primary key auto_increment,  
    user_id unsigned integer not null,
    image_blob blob,
    foreign key fk_user_id (user_id) references user(id) on delete cascade on update cascade,
    .....
    

    3- If you match on username, make sure you have a unique index on that field so no duplicate usernames can exist.
    See the table definition for user above.

    Is it best to store those images in the sql database?

    It is best from a consistency point of view, because the images will fall under the ACID regime enforced by the transactions in InnoDB.
    If you store the images in the filesystem, it is hard to keep the filesystem synced with the DB (if a transaction fails, or a file gets deleted or overwritten the DB and filesystem are out of sync).
    Futhermore, having the application write to the filesystem as well as the DB opens up an extra security problem, which does not exist if the app only communicates with the DB.

    From a performance point of view it can be faster to write the image to the filesystem.
    I would recommend to write to the DB, but to keep open the option to write to the filesystem if and when slowness occurs (but not before).

    Is it as simple as
    SELECT image_blob from Images i

    INNER JOIN user u ON (u.id = i.user_id) WHERE u.name = :userparam

    Yes it’s that simple.

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

Sidebar

Related Questions

Quick question for you. I want to be able to create an instance of
Quick question, If I want to document some code on a basic HTML and
Quick question about Wordpress PHP: I am writing a theme and I want to
Hey guys quick question, I want to update the contents of a div with
Just a quick question about how you would go about implementing this. I want
Quick question. What do you think, I have a few sites that use a
Quick question. There is a legacy website (that is not under my control and
Quick question that requires a long explanation.. Say I have two tables - one
Quick question, which I think has a very easy solution for someone who has
Quick question, I am working on an APNS enabled app and I just want

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.