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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:08:36+00:00 2026-05-21T15:08:36+00:00

I have a table link_tabl in which I want to link three other tables

  • 0

I have a table “link_tabl” in which I want to link three other tables by id. So in every row I have a triplets (id_1, id_2, id_3). I could create for every element of the triplet a column and everything would be fine.

But I want more: =)

I need to respect one more “dimension”. There is an Algorthm who creates the triplets (the linkings between the tables). The algorithm sometimes outputs different linkings.

Example:

table_person represents a person.
table_task represents a task.
table_loc reüpresents a location.

So a triplet of ids (p, t, l) means: A certain person did something at some location.

The tuple (person, task) are not changed by the algorithm. They are given. The algorithm outputs for a tuple (p,t) a location l. But sometimes the algorithm determines different locations for such a tuple. I want to store in a table the last 10 triplets for every tuple (author, task).

What would be the best approach for that?

I thought of something like:
IF there is a tuple (p,t) ALREADY stored in link_table ADD the id of location into the next free slot (column) of the row.
If there are already 10 values (all columns are full) delete the first one, move every value from column i to column i-1 and store the new value in the last column.
ELSE add a new row.

But I don’t know if this is a good approach and if it is, how to realise that…

Own partial solution
I figured out, that I could make two columns. Onw which stores the author id. One which stores the task id. And by

...
UNIQUE INDEX (auth_id, task_id)
...

I could index them. So now I just have to figure out how to move values from column i to i-1 elegantly. =)

Kind regards
Aufwind

  • 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-21T15:08:37+00:00Added an answer on May 21, 2026 at 3:08 pm

    I would store the output of the algorithm in rows, with a date indicator. The requirement to only consider the last 10 records sounds fairly arbitrary – and I wouldn’t enshrine it in my column layout. It also makes some standard relational tools redundant – for instance, the query “how many locations exist for person x and location y” couldn’t be answered by “count”, but instead by looking at which column is null.

    So, I’d recommend something like:

    personID      taskID       locationID        dateCreated
    1             1            1                 1 April 20:20:10
    1             1            2                 1 April 20:20:11
    1             1            3                 1 April 20:20:12
    

    The “only 10” requirement could be enforced by using “top 10” in select queries; you could even embed that in a view if necessary.

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

Sidebar

Related Questions

I have a table which needs to link one of three seperate tables, but
I have table which has about 50 rows. Each row has link, but I
We have a table where rows recursively link to another row. I want to
I have a database table which link locations together; a location can be in
I have created a table view with navigation controller. I want to link table
I have a link ( anchor ) tag in a table cell on every
I want to have a delete user link in a normal Activerecord table, but
I have a table which lists all events on a debating calendar. Each row
I have 2 tables: release_servers and release_components I have a link table release_server_to_components I
I have a table. Call it TableA this table will link to many tables

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.