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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:42:47+00:00 2026-06-08T14:42:47+00:00

The image below is what I have so far. The Design The Emitters Table

  • 0

The image below is what I have so far.

What I have so far

The Design

The Emitters Table

Emitters have their own properties such as location (in terms of x and y), id, level, and the last time this information was updated. More importantly, emitters can be defended by any clan member. Emitters can only be defended by a member of that clan. One emitter can be defended by many players.

The Players Table

Or rather, clan members. This table contains information about the players specifically. This also has location in terms of x and y and other information about that player. (I’ll probably add lastupdated here, too) One player can defend multiple emitters.

The Emitter_Player Join Table

This table contains a single emitter_player combination. (providing one such relationship exists) Let me first ask if this is a proper relationship between emitters and players? I figured it would be many-to-many. Now, I could make this easy on myself and just add defensepoints to this join table (what I really care about is how much "defense" a player has in a specific emitter) Is this also a correct thing to do? However, I’d like to "do it right the first time" and add information about each specific unit a player has defending this emitter.

The Units Table

This table contains information about all of the units in the game. This table has the units id and it’s associated defensive and offensive values. This table will very rarely be inserted into, and when it is (new units are added to the game) it will be updated manually.

The Problem

Fixing the design

Emitters do not contain units outside of players. A player must be the owner of every unit in an emitter. So, there is no relationship between emitters and units. Also, while a player likely has units outside of the emitters, I do not care for this example. I only care about the units that are in an emitter. So, I figured that there would be a many-to-many relationship between the Emitter_Player join table and the Units table. My reasoning behind this is that an Emitter_Player combination can easily have many different types of units and one type of unit can be in many different Emitter_Player combinations.

Inserting information

With two join tables, I am now extremely confused on how to insert information into this database.

Querying information

Again, I am extremely lost how to access information from this database.

The Goal

Graphs

I would like to eventually create graphs (from both players and emitters) showing their progress over time. How I will query this I do not know.

Weekly Changes

I would like to be able to inform players whether they have made progress since last week or lost progress. (and in this case, flag them for review)

Conclusion

I tried to make this as detailed as possible, if you need any more information please let me know. I’m hoping to get this finished soon and I’m really at a complete loss of any ideas further.

  • 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-08T14:42:50+00:00Added an answer on June 8, 2026 at 2:42 pm

    You’re off to a fairly decent start, but I’d recommend a few suggestions:

    It seems to me that you can consolidate the emitters_has_players_has_units table into the emitters_has_players table. Simply make the unit_id a third component in the primary key of emitters_has_players:

    enter image description here

    You’ll also notice I added a quantity column to the particular emitter-player-unit associations. This is necessary to keep track of how many of a particular unit a particular player has for a particular emitter.

    It’s also good practice to keep your column names consistent throughout your database. The way you named your id columns originally was quite long (as it included the full table names as prefixes).


    So here are some examples of how you can query the above design:

    -- Get all associated emitters of a particular player
    SELECT a.*
    FROM   emitters a
    JOIN
    (
        SELECT DISTINCT emitter_id 
        FROM emitters_has_players 
        WHERE player_id = 1
    ) b ON a.emitter_id = b.emitter_id
    

    -- Get all players associated with a particular emitter
    SELECT a.*
    FROM   players a
    JOIN
    (
        SELECT DISTINCT player_id 
        FROM emitters_has_players 
        WHERE emitter_id = 1
    ) b ON a.player_id = b.player_id
    

    -- Get the count of players for a particular emitter
    SELECT COUNT(DISTINCT player_id) AS player_count
    FROM   emitters_has_players
    WHERE  emitter_id = 1
    

    -- Get all units associated with a particular player-emitter association
    SELECT b.*
    FROM   emitters_has_players a
    JOIN   units b ON a.unit_id = b.unit_id
    WHERE  a.emitter_id = 1 AND a.player_id = 1
    

    -- Get the defense points of a particular player-emitter association
    SELECT   SUM(b.averagedefense * a.quantity) AS total_def_pts
    FROM     emitters_has_players a
    JOIN     units b ON a.unit_id = b.unit_id
    WHERE    a.emitter_id = 1 AND a.player_id = 1
    

    -- Create a new player-emitter-unit association
    INSERT INTO emitters_has_players 
    VALUES (1,1,1,1) -- Where the fourth "1" is the quantity of units initially.
    

    -- Player adds on one more of a particular unit for a particular emitter
    UPDATE emitters_has_players
    SET    qty = qty + 1
    WHERE  emitter_id = 1 AND
           player_id  = 1 AND
           unit_id    = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following listbox below which binds to a database table of image
Below is an attached image of what I have so far. 1 = a
I want to create an example like the image below but instead have a
I have to represent graphically an oriented graph like in the image below. alt
In the image below, the top image is what I currently have on a
I have an interface that has large numbers of controls, see image below. Interface
I have three tables as shown in below image. Note: Lead column of projectheader
I have to load the data shown in the below image into my database.
I have setup background image for a button as below. // declarations globally declared...
I have an xml as below < Image>ImageValue1 <Type>png</Type> <Value>ImageValue1</ Value> </ Image> Here

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.