Database Schema - reddcoin-project/reddcoin GitHub Wiki

Database Schema

The ReddID system uses a comprehensive database schema to store and manage all identity-related data with efficient indexing and querying capabilities.

Entity Relationship Diagram

Core Tables

Namespace Tables

namespaces

Stores information about all registered namespaces.

Column Type Description
id VARCHAR(15) Namespace identifier (PK)
owner BLOB Owner's address in binary format
allow_numbers BOOLEAN Whether numbers are allowed
allow_hyphens BOOLEAN Whether hyphens are allowed
allow_underscores BOOLEAN Whether underscores are allowed
min_length INT Minimum name length
max_length INT Maximum name length
renewal_period INT Days until renewal required
grace_period INT Days in grace period
namespace_revenue_pct INT % of auctions going to namespace owner
burn_pct INT % of auctions being burned
node_pct INT % of auctions going to node operators
dev_pct INT % of auctions going to development fund
min_auction_duration INT Minimum auction duration in days
max_auction_duration INT Maximum auction duration in days
min_bid_increment REAL Minimum bid increment percentage
config_hash BLOB(32) Hash of this configuration
last_updated INT64 When configuration was last updated
expiration INT64 When namespace ownership expires

namespace_pricing_tiers

Stores pricing tiers for different name lengths within a namespace.

Column Type Description
namespace_id VARCHAR(15) Namespace identifier (PK, FK)
min_length INT Minimum length for this tier (PK)
min_price INT64 Minimum price for names in this tier

User ID Tables

user_ids

Stores information about registered user IDs within namespaces.

Column Type Description
name VARCHAR(64) Name portion of the ID (PK)
namespace_id VARCHAR(15) Namespace portion of the ID (PK)
owner BLOB Owner's address in binary format
registration_time INT64 When the ID was registered
expiration_time INT64 When the ID expires
last_transaction INT64 Timestamp of last transaction
transaction_count INT Number of transactions
metadata_hash BLOB(32) Hash of additional metadata

Auction Tables

auctions

Stores information about all auctions in the system.

Column Type Description
auction_id BLOB(32) Unique identifier for the auction (PK)
name VARCHAR(64) Name portion of the ID being auctioned
namespace_id VARCHAR(15) Namespace portion of the ID
creator_address BLOB Creator's address in binary format
start_time INT64 Start time (unix timestamp)
end_time INT64 End time (unix timestamp)
reserve_price INT64 Minimum acceptable bid
current_bid INT64 Highest current bid amount
current_bidder BLOB Address of highest bidder
deposit_amount INT64 Required deposit amount
state INT Current auction state
type INT Auction type (0=standard, 1=premium, etc.)
metadata_hash BLOB(32) Hash of additional metadata
block_height INT Block height when auction was created
txid BLOB(32) Transaction ID of creation transaction

bids

Stores information about all bids placed.

Column Type Description
bid_id BLOB(32) Unique identifier for the bid (PK)
auction_id BLOB(32) Reference to the auction (FK)
bidder_address BLOB Bidder's address in binary format
bid_amount INT64 Bid amount
deposit_amount INT64 Deposit amount paid
bid_time INT64 Time when bid was placed
txid BLOB(32) Transaction ID of the bid transaction
is_winner BOOLEAN Whether this bid won the auction
refunded BOOLEAN Whether the deposit was refunded

ReddID Profile Tables

reddid_profiles

Stores core profile information for each ReddID.

Column Type Description
reddid VARCHAR(32) The ReddID (PK)
owner BLOB Owner's address in binary format
display_name VARCHAR(64) User-selected display name
avatar_hash BLOB(32) IPFS hash of avatar image
bio VARCHAR(256) Short biography or description
email_hash BLOB(32) Hash of verified email (optional)
social_data TEXT JSON of linked social profiles
messaging_pubkey BLOB Public key for encrypted messaging
verification_status INT Verification level (0-3)
creation_time INT64 When the ReddID was created
last_updated INT64 When profile was last updated
expiration_time INT64 When the ReddID expires
active BOOLEAN Whether the ReddID is currently active
flags INT Bitfield of profile flags/settings

reddid_connections

Stores social connections between ReddIDs.

Column Type Description
from_reddid VARCHAR(32) Source ReddID (PK)
to_reddid VARCHAR(32) Target ReddID (PK)
connection_type INT Type (0=follow, 1=friend, 2=endorse, 3=block)
creation_time INT64 When connection was established
last_interaction INT64 When last interaction occurred
visibility INT Privacy setting (0=public, 1=friends, 2=private)
metadata TEXT Additional connection metadata
txid BLOB(32) Transaction ID of the connection operation

reddid_reputation

Stores reputation information for ReddIDs.

Column Type Description
reddid VARCHAR(32) The ReddID (PK)
overall_score REAL Aggregate reputation score (0-100)
longevity_score REAL Score component for account age
transaction_score REAL Score component for transaction history
engagement_score REAL Score component for community engagement
verification_score REAL Score component for verification depth
auction_score REAL Score component for auction behavior
last_calculated INT64 When the score was last calculated
calculation_proof BLOB Proof of calculation correctness
calculator_signatures TEXT JSON of node signatures validating the calculation

reddid_namespace_resolution

Maps ReddIDs to namespace-specific user IDs.

Column Type Description
reddid VARCHAR(32) The ReddID (PK)
namespace_id VARCHAR(15) Namespace identifier (PK)
user_id VARCHAR(64) User ID within that namespace
is_primary BOOLEAN Whether this is the primary namespace for the ReddID
auto_update BOOLEAN Whether profile changes propagate to this namespace
last_synced INT64 When last synchronized

Indexes

The database uses several indexes to optimize common queries:

  • Indexes on foreign keys for efficient joins
  • Indexes on auction state for finding active auctions
  • Indexes on expiration times for renewal management
  • Indexes on reputation scores for ranking
  • Composite indexes for namespace-specific user ID lookups
⚠️ **GitHub.com Fallback** ⚠️