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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:52:29+00:00 2026-05-14T14:52:29+00:00

I want that its name would be the page address. For example, if page

  • 0

I want that its name would be the page address. For example, if page has heading “Some Page”, than its address should be http://somesite/some_page/.
“some_page”-name generated by system automatically. “some_page” – is the unique identifier of page. The problem in that the user in the future can enter a name which already exists that will cause an error.

It is necessary to find an optimum variant of the decision of a problem for great volumes of the data.

I have solved a problem as follows:
The page identifier in a database is the name of page and a suffix which is by default equal to zero. At page addition there is a check on existence. If such page does not exist, the suffix is equal 0 and its name is “some_page”, if page is exist, than – search for the maximum number of a suffix and suffix=suffix+1 and page name become “some_page_1”.

For this I create in a database the compound key from fields “suffix” and “pageName”:

Table Pages

suffix|pageName  |pageTitle
0     |some_page |Some Page
1     |some_page |Some Page
0     |other_page|Other Page

Addition of pages occurs through stored procedure:

CREATE PROCEDURE addPage (pageNameVal VARCHAR(100), pageTitleVal VARCHAR(100)) 

BEGIN

    DECLARE v INT DEFAULT 0;

    SELECT MAX(suffix) FROM pages WHERE pageName=pageNameVal INTO v;

    IF v >= 0 THEN

        SET v = v + 1;

    ELSE

        SET v = 0;

    END IF;

    INSERT INTO pages (suffix, pageName) VALUES (pageNameVal, v, pageTitleVal);

END;

Whether there are more the best decisions?

  • 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-14T14:52:29+00:00Added an answer on May 14, 2026 at 2:52 pm

    I think this should be okay – it would keep multiple instances of the key distinct. However, why not use a generated key instead of something provided by the user? If you maintain control over the page’s lookup ID, you’ll ensure no duplicates. Your current setup shouldn’t cause any trouble, though.

    The only problem (though it seems highly unlikely), is that your SP has a chance to duplicate the suffix for a particular key if two callers try to save the same key at the same time – ie, two simultaniousrequests with the same brand new pagename could both end up trying to use suffix 0. If you don’t care about the result of your insert statement (and your current SP doesn’t return it), then just do it in a single statement inside your SP:

    CREATE PROCEDURE addPage (pageNameVal VARCHAR(100), pageTitleVal VARCHAR(100)) 
    BEGIN
    
        INSERT INTO pages (pageName, suffix, pageTitle)
        SELECT n.pageNameVal, ISNULL(NextValue, 0), n.pageTitleVal
          FROM (SELECT pageNameVal, pageTitleVal) n
          LEFT
          JOIN (SELECT MAX(suffix+1) as NextValue FROM pages WHERE pageName=pageNameVal) m
    
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SCENARIO: Given that a model called Edition has its community feature enabled I want
I want to make a page that has a table of various webpages with
Im not sure that its possible to do what I want to accomplish. I
I have one array. I want that array to retain its value between function
I want to create a separate thread that runs its own window. Frankly, the
For my application, I want a Combo Box that displays its elements when dropped
My problem is that I want to have a tab bar view with its
We have a python project that we want to start testing using buildbot. Its
Using WPF, I have a TreeView control that I want to set its ItemTemplate
I want to show the image that mobile phone's camera its taking on a

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.