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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:29:31+00:00 2026-05-18T07:29:31+00:00

I have a MySQL table , each row representing a Person. For each person

  • 0

I have a MySQL table , each row representing a Person. For each person I would like to show a list of related links (when generating his page on my website), so I created a column called “RelatedLinks” which there I save raw HTML content such as:

<a href="domain1.com">Related Link 1</a> <a href="domain2.com">Related Link2</a>

Then I just use PHP to echo $row["RelatedLinks"]; within the HTML itself.

The problem with this implementation is that I have little control over the links, for example in changing their order of appearance on the website, deleting/editing a specific link and so on.

The second idea I thought about was to create a column in the table for each related link, such as “RelatedLink1”, “RelatedLink2” and then use PHP to echo $row["RelatedLink1"] . "<br />" . $row["RelatedLink2"].

Although I do have much more control with this implementation, I think I am creating a big overhead in the table.

What is an efficient way to achieve this functionality?


EDIT

Referring to Gabriel’s answer, the question now is about complexity:

With the current implementation, once I select the person I have all the links in my hand – complexity of O(1). What will be the complexity of running a query to select all foreign keys of the current Person, as suggested by Gabriel (and Haim) below?

Thanks,

Joel

  • 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-18T07:29:31+00:00Added an answer on May 18, 2026 at 7:29 am

    If you only want to store and display the links, and the edit actions are very few, the first option is the best one. In this case, you will have to save the new values on edit.

    If you think you’ll have more edit operations, you could try to create a second tabel, to contain id_pearson, link, text, order . And you can use this tabel to edit the links for a specific pearson.

    Also, if you need the same link for two or more persons, it’s preferable to use 3 tables.

    persons table : id_person, name (and all other info)

    links table : id_link, text, link

    person_links : id_person, id_link, order

    Using this setup, you can edit the links in one place, and all persons will have access to the same version.

    LATER EDIT IN RESPONSE TO COMMENT

    Okey, regarding complexity of operations, nothing could beat the first solution. But you must take in account several things regarding what you need:

    • how often do you expect to change the links ?
    • who is gone change the links (the admin of the site, or the end user) ?
    • how many cases of the same link to appear for different persons (using the first solution, you will have to edit all persons that contain that link )

    To answer your question of complexity, the solutions proposed by me are O(n) if I’m not mistaking. Using foreign keys and proper indexing in MySql, you shouldn’t have a problem with this.

    Summary: if performance is very important to you and the links will be edited only by the admin, use the first solution. If not, I would use the third one.

    Hope this helps,
    Gabriel

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

Sidebar

Related Questions

I have a MySQL table that will only have one row. What should my
i have a table in whitch each row have a date variable. i want
I have an articles table with a tags column. Each row in the column
I have a MySQL table with approximately 3000 rows per user. One of the
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION
I have a mysql table that relies on the unix epoch time stamp equivalent
I have a MySQL table consisting of: CREATE TABLE `url_list` ( `id` int(10) unsigned
I have a MySQL table with utf8 general ci collation. In the table, I
I have a MySQL table holding lots of records that i want to give

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.