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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:52:05+00:00 2026-06-16T20:52:05+00:00

I am currently refactoring a project where so far a lot of data was

  • 0

I am currently refactoring a project where so far a lot of data was kept as constants and arrays in the code. Also there are a lot of redundancies. Now I want to move all that data into the db, but I am not sure how I would do the mapping. The data is rarely dynamically selected based on user input but rather specifically selected in the code. It is used at a very core level of the application, but it is actually not THE core. Also a database is already being used, so there would be no real extra effort.

My idea would be to use a Mapping class in which I have constants pointing to the IDs of the respective rows. Is that a good idea?

Another idea would be to index the name row and just directly query for the names.

The database would probably have the following columns: id, name, polynom and params.
So, basically we are talking math data. For example: 1, “Price approximation”, 20x^3 – 5x^2 + 11x”, “non-cumulated”.

I think this question is language-agnostic but since there might be a language-specific (or even framework-specific) best practice, here is what I use: PHP5 with the Yii Framework.

  • 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-06-16T20:52:07+00:00Added an answer on June 16, 2026 at 8:52 pm

    I don’t have much experience with PHP nor Yii, but here is my 2 cents…

    If these are constants and collections of constants that technically define your application (application architecture constants), but the end-user shouldn’t have control over, I would put them in a configuration file instead of your database, unless you’ve built a module to easily access and modify them. Whether you implement a mapping class (or a configuration class) to retrieve them is not important, but be consistent in how you retrieve them. If you have too many to manage in a configuration file, then storing them in the database would be appropriate, but make sure you provide an easy way to modify them. To make your source code readable, I’d use descriptors that a human can understand and map those descriptors to the respective row like you mentioned.

    If these are user defined constants, then you should definitely provide an interface. But keep the same architecture as the application architecture constants.

    In a perfect program/application (or even better–an application framework), nothing is hard coded, and everything is controlled by constants (switches). If you’re able to achieve this successfully without the need to maintain your source code, you will win the Nobel Peace Prize.

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

Sidebar

Related Questions

I'm refactoring a project that involves passing around a lot of arrays. Currently, each
i'm currently refactoring a C-project, throwing about 1000 warnings at me. is there a
I'm currently refactoring/tidying up some old C code used in a C++ project, and
I am currently refactoring a project which has been halfheartedly ported to Yii. There
I'm currently refactoring some code on a project that is wrapping up, and I
I'm currently refactoring some Javascript code we have and amongst other things I've changed
I have an ASP.net Web Site Project (.net 3.5). Currently all of the non-code
I have been refactoring the codebase of the project that I am currently on
I am currently refactoring my project and one thing I'm not quite sure on
I have been tasked with refactoring a project that currently uses an EAV model

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.