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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:52:33+00:00 2026-05-21T17:52:33+00:00

I am about to design a database for a logging system. Many of the

  • 0

I am about to design a database for a logging system.

Many of the String columns will have a limited amount of values, but not known in advance:
Like the name of the modules sending the messages, or the source hostnames.

I would like to store them as MySQL Enums to save space.
So the idea would be that the Enums grow as they encounter new values.

I would start with a column like :

host ENUM('localhost')

Then, in Java, I would load on startup the enum values defined for the hostnames at a time (how do I do that with MySQL/JDBC ??), and I would alter the Enum whenever I encounter a new host.

Do you think it is feasible / a good idea ?
Have you ever done something like that ?

Thanks in advance for your advice.

Raphael

  • 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-21T17:52:34+00:00Added an answer on May 21, 2026 at 5:52 pm

    This is a not good idea. ENUM designed not for that.
    You can just create separate table (host_id, host_name) and use refference in main table. Example:

    CREATE TABLE `host` (
        `host_id` INT(10) NOT NULL AUTO_INCREMENT,
        `host_name` VARCHAR(50) NULL DEFAULT NULL,
        PRIMARY KEY (`host_id`)
    )
    
    CREATE TABLE `log` (
        `log_id` INT(10) NOT NULL AUTO_INCREMENT,
        `host_id` INT(10) NULL DEFAULT NULL,
        ...
        PRIMARY KEY (`log_id`),
        INDEX `FK__host` (`host_id`),
        CONSTRAINT `FK__host` FOREIGN KEY (`host_id`) REFERENCES `host` (`host_id`) ON UPDATE CASCADE ON DELETE CASCADE
    )
    

    UPD:

    I think the best way to storing host is varchar/text field. It is easiest and fastest way. I think you need not worry about the space.

    Nonetheless.

    Using the second table for hosts will reduce the size, but will complicate writing logs. Using ENUM complicate writing and significantly reduce the performance.

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

Sidebar

Related Questions

I have posted a question about multilanguage database design here, [] What are best
This is a general question about mongodb database design, but the reason for my
I have two options about database design. Edit: It is used for storing the
I have a question about Database design. I have two tables, usertable and historytable,
I have a database design problem , where the database object's properties are not
I'm designing a database schema using PostgreSQL. I have some doubts about which design
Quick question about database design. If I have two databases: User_DB and Group_DB, and
I have been thinking about database design lately and I have the following question:
I am currently thinking about the database design of a 'friends' table (many-to-many, stores
Hi there I have a short question about database design. I also tried the

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.