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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:40:33+00:00 2026-05-24T19:40:33+00:00

I am creating a new URL shortener and have read that a Bijective function

  • 0

I am creating a new URL shortener and have read that a Bijective function is what is required. So, I found Jon Skeet’s BiDictionary (excellent) and wondered how I’d use this within the URL shortener application. Currently, I Base36 encode the database ID column to create my shortened URL and store the full URL into the table. This works fine but I’m lost as to why I need to use a Bijective function? Do I store the values from the database into the Bijective Dictionary? Is what I currently have functional enough? What would the benefits be of using a Bijective Dictionary?

  • 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-24T19:40:34+00:00Added an answer on May 24, 2026 at 7:40 pm

    Not really sure that I understand you question fully…

    If I understand you correctly you have created a lookup table with a unique ID and a URL.
    Your shortened URL is the Base36 encoded ID.

    Let’s look at the use cases:

    • Create a shortened URL
      means in you implementation check whether you already have that URL in the table (simple, just return the Base36 encoded ID).
      Otherwise just create a new entry and return the Base36 encoding of the new ID.

    • Lookup the full URL
      Decode the Base36 value to an ID, lookup the ID in the table and return -if found- the full URL.

    So basically you have created a bijective function (a bidirectional 1:1 correspondence) – just something that works in both directions without any loss, thus fully invertible regarding the given URLs in your table. The Base36 encoding/decoding is fully invertible too so that is a bijective function too 🙂

    The BiDictionary from Jon you mention would be good base for an in-memory-cache (recommend write-through) so you can avoid the DB roundtrip where possible. The Bidictionary uses Dictionary while for a cache which can be accessed by multiple threads I would strongly recommend using ConcurrentDictionary . In your case the List<> part from Jon’s implementation is not needed since you always would have a 1:1 correspondence. For faster lookup you could use the Base36 encoded value as a key…

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

Sidebar

Related Questions

I have such view that handles user registration. After creating new user i want
I have a URLConnection, that access a web page. URL url = new URL(https://domain);
I'm creating a new Flex component (Flex 3). I'd like it to have a
I'm currently working on creating a new C# project that needs to interact with
I'm creating a new url infrastructure for my sites, and came across this problem:
I have a new web app that is packaged as a WAR as part
How can I change (relocate) a subversion url that I entered when creating a
I have a form where I have an administrator creating new users. The form
I'm creating a new blog form and I have a few photo upload fields
When creating a new file with vim, I would like to automatically add some

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.