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

  • Home
  • SEARCH
  • 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 4578810
In Process

The Archive Base Latest Questions

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

Is it an ok practice to have a URL column in my database that

  • 0

Is it an ok practice to have a URL column in my database that would store a URL such as: /this-is-a-keyword

And then use that column in my php query to get the information I need instead of using an integer column?

So basically when I went to Mysite.com/this-is-a-keyword I would return the result from that row.

  • 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-21T20:33:18+00:00Added an answer on May 21, 2026 at 8:33 pm

    More or less, what you are describing is called a slug and it’s normally constructed by passing the most descriptive string (usually the title of the page / post) to a slugify function, like this one:

    function Slug($string)
    {
        return strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
    }
    

    The problem with this, however, is that the result may not be unique, consider the following:

    echo Slug('Alix Axel');          // alix-axel
    echo Slug('Álix Ãxel');          // alix-axel
    echo Slug('@Álix----_Ãxel!?!?'); // alix-axel
    

    All return the same output even though the input differs. One of my favorite (and also most widespread) approaches is to do like StackOverflow does it (using the ID and slug in combination):

    stackoverflow.com/questions/5845732/clean-urls-and-database

    If you want to avoid this, you need to make sure the slug you are generating does not exist already in the database, if it does append an incremented number until it satisfies the unique condition.

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

Sidebar

Related Questions

I have a two part question Best-Practice I have an algorithm that performs some
Is it good practice to have a class constructor that uses default parameters, or
Is it good practice to have a unit test that specifies how long a
I have heard that using exception trapping is not a recommended practice for number
Is it good practice to have more than one try{} catch{} statement per method?
Is it bad practice to have a string like name=Gina;postion= HouseMatriarch;id=1234 to hold state
Are there good reasons why it's a better practice to have only one return
In general, is it a best practice to have simple POJO Java classes implement
From what I have read best practice is to have classes based on an
Is there a best-practice or common way in JavaScript to have class members as

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.