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

  • Home
  • SEARCH
  • 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 427595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:35:31+00:00 2026-05-12T19:35:31+00:00

I have a database that tracks players through their attempts at a game. To

  • 0

I have a database that tracks players through their attempts at a game. To accomplish this, I keep a table of users and store the attempts in a separate table. The schema for these tables is:

CREATE TABLE users (
  id BIGINT PRIMARY KEY,  -- the local unique ID for this user
  name TEXT UNIQUE,  -- a self-chosen username for the user
  first_name TEXT,  -- the user's first name
  last_name TEXT,  -- the user's last name
  email TEXT,  -- the user's email address
  phone TEXT  -- the user's phone number
);

CREATE TABLE trials (
  timestamp TIMESTAMP PRIMARY KEY,  -- the time the trial took place
  userid BIGINT, -- the ID of the user who completed the trial
  score NUMERIC,  -- the score for the trial
  level NUMERIC,  -- the difficulty level the trial ran at
  penalties NUMERIC  -- the number of penalties accrued in the trial
);

Now I need to be able to store attempts that come from “transient” users. These attempts should not be linked back to an existing user. However, these transient users will still be able to enter a name that displays in the results. This name is not required to be unique in the table, since it does not represent a “real” user.

My first thought was to create a new field in the trials table called name. If userid is null, I would know it is a transient user, but I would still be able to show the name fields in the results. This approach doesn’t quite smell right, and it seems like it will make my queries a bit more complicated. Additionally, it seems like I’m duplicating data in a sense.

Another thought was to replace userid with a useref text field that would be some kind of formatted string representing the user. For example, if the value were enclosed in curly braces, I would know it’s an ID, i.e. {58199204}. If the value were not enclosed, I would treat it as a transient user. This more accurately represents what I’m trying to do conceptually (i.e. it’s either an ID or a transient user string), but it would really complicate my queries.

I’m using SQLite for the backend… It lacks some of the extended features of SQL Server or MySQL.

Any thoughts on these or another approach to the problem?

  • 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-12T19:35:31+00:00Added an answer on May 12, 2026 at 7:35 pm

    Without more information about why a transient user can use but not exist in the system, I concur with your idea to:

    1. Add a NAME column to the TRIALS table
    2. Make the USER_ID column in the TRIALS table nullable/optional in order to indicate transient user status

    If you could allow a transient user to exist in the system, I would recommend:

    1. Creating a USER_TYPE_CODE table
    2. Update the USERS table to include the USER_TYPE_CODE column (w/ foreign key reference to the USER_TYPE_CODE table)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 260k
  • Answers 260k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See the docs for the setdefault() method: setdefault(key[, default]) If… May 13, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer I can't give you any details about the quality (though… May 13, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer Use the "g" modifier: function extractURLs(s) { return s.match(new RegExp(urlPattern,… May 13, 2026 at 11:29 am

Related Questions

I am creating a database that tracks replays for a game. Each replay has
I have a table which needs 2 fields. One will be a foreign key,
I have been tasked with developing a solution that tracks changes to a database.
I'm working on a database that tracks files and dependencies in projects. Briefly, I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.