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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:52:23+00:00 2026-05-11T00:52:23+00:00

I have a table representing values of source file metrics across project revisions, like

  • 0

I have a table representing values of source file metrics across project revisions, like the following:

Revision FileA FileB FileC FileD FileE ... 1           45     3    12   123   124 2           45     3    12   123   124 3           45     3    12   123   124 4           48     3    12   123   124 5           48     3    12   123   124 6           48     3    12   123   124 7           48    15    12   123   124 

(The relational view of the above data is different. Each row contains the following columns: Revision, FileId, Value. The files and their revisions from which the data is calculated are stored in Subversion repositories, so we’re trying to represent the repository’s structure in a relational schema.)

There can be up to 23750 files in 10000 revisions (this is the case for the ImageMagick drawing program). As you can see, most values are the same between successive revisions, so the table’s useful data is quite sparse. I am looking for a way to store the data that

  • avoids replication and uses space efficiently (currently the non-sparse representation requires 260 GB (data+index) for less than 10% of the data I want to store)
  • allows me to retrieve efficiently the values for a specific revision using an SQL query (without explicitly looping through revisions or files)
  • allows me to retrieve efficiently the revision for a specific metric value.

Ideally, the solution should not depend on a particular RDBMS and should be compatible with Hibernate. If this is not possible, I can live with using Hibernate, MySQL or PostgreSQL-specific features.

  • 1 1 Answer
  • 2 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. 2026-05-11T00:52:23+00:00Added an answer on May 11, 2026 at 12:52 am

    This is how I might model it. I’ve left out the Revisions table and Files table as those should be pretty self-explanatory.

    CREATE TABLE Revision_Files (     start_revision_number   INT NOT NULL,     end_revision_number     INT NOT NULL,     file_number             INT NOT NULL,     value                   INT NOT NULL,     CONSTRAINT PK_Revision_Files PRIMARY KEY CLUSTERED (start_revision_number, file_number),     CONSTRAINT CHK_Revision_Files_start_before_end CHECK (start_revision_number <= end_revision_number) ) GO 

    To get all of the values for files of a particular revision you could use the following query. Joining to the files table with an outer join would let you get those that have no defined value for that revision.

    SELECT     REV.revision_number,     RF.file_number,     RF.value FROM     Revisions REV INNER JOIN Revision_Files RF ON     RF.start_revision_number <= REV.revision_number AND     RF.end_revision_number >= REV.revision_number GO 

    Assuming that I understand correctly what you want in your third point, this will let you get all of the revisions for which a particular file has a certain value:

    SELECT     REV.revision_number FROM     Revision_Files RF INNER JOIN Revisions REV ON     REV.revision_number BETWEEN RF.start_revision_number AND RF.end_revision_number WHERE     RF.file_number = @file_number AND     RF.value = @value GO 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table of TIME datatypes clarification: I am representing hours/mins/seconds of
I have a View with a table representing an employee's timesheet. Days across the
I have a sqlite table representing a weighted directed graph. The columns are as
I have a table containing an url and a string representing its parameters. The
I have a simple temp-table defined in SQL Server 2008 R2 representing a parent-child
Hey all, quick NHibernate question. In my current project, we have a denormalized table
I have a table with data representing a tree structure, with one column indicating
I have this table which has seven columns, each column representing a specific value
In my table of products I have a field representing an attributeset. The attributeset
I have to create a table and store Active Directory SIDs representing an User

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.