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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:19:12+00:00 2026-06-05T15:19:12+00:00

I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (

  • 0

I have this database structure,

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

CREATE TABLE IF NOT EXISTS `announces` (
   `tracker` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
   `failCount` smallint(5) unsigned NOT NULL DEFAULT '0',
   PRIMARY KEY (`tracker`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `hashes` (
   `hash` binary(20) NOT NULL,
   `indexed` tinyint(1) NOT NULL DEFAULT '0',
   PRIMARY KEY (`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `trackers` (
   `hash` binary(20) NOT NULL,
   `tracker` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
   `seeders` mediumint(8) unsigned NOT NULL DEFAULT '0',
   `leechers` mediumint(8) unsigned NOT NULL DEFAULT '0',
   KEY `hashFK` (`hash`),
   KEY `trackerFK` (`tracker`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `trackers`
   ADD CONSTRAINT `hashFK` FOREIGN KEY (`hash`) REFERENCES `hashes` (`hash`)
   ON DELETE CASCADE,
   ADD CONSTRAINT `trackerFK` FOREIGN KEY (`tracker`) REFERENCES `announces` (`tracker`) 
   ON DELETE CASCADE;

The table trackers has 2 foreign keys one for trackers, and one for hashes.

This I think makes sure that a hash cannot be in trackers without first being in hashes. And if a hash is deleted from hashes then it also gets deleted from trackers.

Same for trackers, a tracker must exist in announces before it can exist in trackers, and if it gets deleted from announces it also gets deleted from trackers.

The problem I have is that a hash should only exist in trackers if the corresponding value of indexed in the hashes row is == 1. Is this possible?

  • 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-06-05T15:19:13+00:00Added an answer on June 5, 2026 at 3:19 pm

    If what you wish is to raise an error whenever a tracker is inserted with a fk to a hash with indexed != 1, then it has to be implemented at the applicative layer.

    Various options:

    • favorite coding language checks (subsequent queries to check values before insertions)
    • using triggers, before insert into tracker, check that the corresponding hash is indexed, and if not cancel/raise error

    cheers

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

Sidebar

Related Questions

I have the following mysql table schema: SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -- -- Database: `network` --
I have created a table on an Oracle 10g database with this structure :
I have a SQL database table with the following structure: create table category_value (
So I have this table in my database Item Cat1 Cat2 -------------------- Aaa Red
I have this old Access database (2000 format) which i want to convert to
In mysql database i have this column called: Name: Date Type: datetime I have
I have this algorithm in Java to store passwords in database. I'd like to
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have this question in which I have a SQL Server Compact Edition database
i have this PHP code, and a DataBase with Question, answer1, answer2, Question_id well,

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.