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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:20:23+00:00 2026-05-25T19:20:23+00:00

I have a 1000×1000 matrix, with some data in each entry. Is it possible

  • 0

I have a 1000×1000 matrix, with some data in each entry.

Is it possible to store it sequentially (ie, a row next to the previous one) in a table? I mean, if I could just access the table “by offset” (just like an array), given I won’t add/delete any entry, I would save space for the key, which is blatantly redundant here.

Is it possible? Thanks!

  • 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-25T19:20:23+00:00Added an answer on May 25, 2026 at 7:20 pm

    Tables don’t have an order. There is no sequence to them. The key is not redundant because it tells you how to access your data. If I were to model this I would do it like so:

    CREATE TABLE My_Matrix AS (
        row_num    SMALLINT    NOT NULL,
        col_num    SMALLINT    NOT NULL,
        value      INT         NOT NULL, -- Or whatever data type is appropriate
        CONSTRAINT PK_My_Matrix PRIMARY KEY CLUSTERED (row_num, col_num),
        CONSTRAINT My_Matrix_row_num_chk CHECK (row_num BETWEEN 1 AND 1000),
        CONSTRAINT My_Matrix_col_num_chk CHECK (col_num BETWEEN 1 AND 1000)
    )
    

    Now, if you want to get a value by row number and column number then you can quickly get that with:

    SELECT value FROM My_Matrix WHERE row_num = @row_num AND col_num = @col_num
    

    If you want to get it by an offset then you could use something like:

    SELECT
        value
    FROM
        My_Matrix
    WHERE
        row_num = @value%1000 AND
        col_num = @value/1000
    

    As for saving storage, you’re talking about 4 bytes per row here, with a matrix that has a maximum of 1M rows. For any serious RDBMS that’s pretty irrelevant.

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

Sidebar

Related Questions

I am trying to generate some test data. Say I have 1000 appointments that
I have 1000 rows of data but need to only display 100 rows at
I have a matrix having around 1000 geospatial points(Longitude, Latitude) and i am trying
I am running an import that will have 1000's of records on each run.
Let's say I have 1000 files to read and because of some limits, I
I have 1000 files in a directory. I'm on a solaris machine I want
Hi I have 1000 encrypted workbooks which I would like to decrypt by providing
I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees
We have 5mb of typical text (just plain words). We have 1000 words/phrases to
Are there any html helpers for page navigation. eg. if i have 1000 records

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.