What I am storing
I'm trying to store a list of URLs and nothing else. My goal is to have a list of blacklisted URLs and I can add to this list when I want and I want to read from the list with O(1)
time complexity if possible.
I've read a few answers here where it was suggested that it can be a good design to create a table with only one column if really needed.
How I'm storing
Of course, having only one column means having only the primary key stored. In this case, the MD5 hash of the URL is generated and inserted into the database as the primary key. The list can be very large (hundreds of thousands) but collisions are unlikely so they're not important for now. So just imagine they won't happen.
I'm using MySQL
if that matters.
My question
- What is the time complexity of adding a new URL to this database?
- What is the time complexity of checking if a URL exists?
Also, any sample query for table creation, insert, and update is appreciated as I'm new to SQL.