The most generic e-shop DB schema

Let’s say I create a schema for an e-shop what potentially sells everything: laptops, phones, tires, snacks etc. Considering this, I cannot create a new table/entity for each good category the shop sells and describe the good’s properties by new attributes.

So, I went to more generic model to describe each product To me, it seems fine but as soon as I’ve tried to implement this solution, it’s appeared to impossible to execute any query like

select names and prices of all laptops where ssd capacity >= 512 and weight < 2kg and price <= 2000 money

How is possible to change this schema and keep the ability to store information about any product?

Which class gives most new magical powers for 1 level dip

Background: I have a bard, who is a bit lacking in low level spell selection, so I’ve been looking into multiclassing to get some more.

Stats (you can give +2 ASI for the benefit of multiclassing):

STR 11, DEX 17, CON 14, INT 9, WIS 14, CHA 20

So, Wizard is out.

For classes that pick subclass at level 1, subclass features count of course.

From what I have gathered from unofficial internet snippets, Tasha’s Cauldron of Everything seems give some nice options (like 4 cantrips and 5 1st level spells?!). But I don’t have that book myself to verify, and I may have missed other options, so the question:

What is the most different spells or spell-like powers a 1-level multiclass dip can give?

To clarify: I mean spells the character can actually have available, not the number they can choose from. I also realize now, that divine casters who pick spells every morning are their own category, not directly comparable. Still, for purposes of this Q, count the daily prepared spells.

Bard isn’t option for me, so I’ll include it as an example: 4 cantrips, 2 spells, 1 magical ability (Bardic Inspiration).

UA is ok, though I’d prefer official classes.

Would a bat familiar have a passive perception of 16 in most cases?

In its stat block a bat is shown to have a passive perception of 11; the standard 10 plus wisdom. However, the bats ability Echolocation states that it "can’t use its blindsight while deafened", which heavily implies that the bat relies on hearing for detection. This married with its other ability Keen Hearing which says that a bat has "advantage on Wisdom (Perception) checks that rely on hearing" and the knowledge that advantage on perception checks also translates to a +5 to passive perception makes me think that barring special cases (such as perception checks that rely on detecting a certain smell), a bat should be treated as having a passive perception of 16.

Is this correct, or is there a reason a bats perception would stay at 11?

Theorycraft: What’s the most self-sufficient character possible? [closed]

So this is a theorycraft idea that’s been floating around my head for quite a while now: what’s the most self-sufficient character possible in D&D 5e? Assuming we use the game’s rules and lore/fluff of the "default D&D setting" as reference.

What do you mean by self-sufficient?

Let’s use a story as an example: imagine your new DM turned out to be an Evil Demigod who kidnaps you into the world of his D&D campaign. There’s an empty character sheet in front of you, and as soon as you fill it out (according to normal character creation rules), he’s going to reincarnate you as that character and start his evil campaign.

Now, as you mull over what kind of character you should create, you think about the few key pieces of information you found out:

  • The only way you can escape this hellish fantasy world is by beating the campaign
  • The DM wants you dead, but he can’t just go "Rocks Fall, everyone dies". He must kill you in an at least somewhat fair and legitimate manner.
  • The DM’s campaign is, in fact, beatable, and with the perfect strategy, the success rate is above 50% (dicerolls and RNG included).
  • The evil DM’s world follows the rules and lore of the game, so you can get away with cheesy exploits such as wish+simulacrum or coffelock. (You’ll see why they don’t matter in a second)
  • The DM will take it easy at first, so let’s assume that you’re able to survive the early levels and also find some kind of ridiculous cheese that allows you to reach level 20+ (You gain an Epic Boon for every 30’000 exp past lvl 20).

The Obstacles

So if we want to maximize our chances of making it through anything our evil DM throws at us, what problems do we need to solve?

1. Party Members

D&D is (I think) a game where you’re supposed to rely on your companions for solving problems you yourself can’t handle. However, it’s all but guaranteed that the DM will find a way to separate the party, possibly for years on end. So, everyone needs to be self-sufficient anyways.

2. Magic and the Weave

Magic in D&D is very powerful, capable of solving most problems. It also becomes completely useless once we find ourselves in an Dead Magic Zone. As far as i know, all magic in D&D depends on the Weave. This includes things like Ki, Psionics, and perhaps even Divine Magic. Wouldn’t it be a shame if an Eldrich Horror from the Far Realms came along and ate the entirety of the Weave for lunch? This would turn the entire multiverse into an giant Antimagic Field. But we still need a way to kill monsters immune to nonmagical bludgeoning/piercing/slashing damage! The Monk’s Ki-empowered strikes feature, as well as similar features such as the Warlocks Pact Weapon, were confirmed to be supressed in Antimagic Fields, so they’re out of the window. All that’s left are mundane means, Artifacts, or Deities. Speaking of Deities…

3. Divine Intervention

You might be tempted to rely on a God’s power – after all, spells cast by them aren’t suppressed by antimagic. Unfortunately, gods in D&D, especially in epic-level campaigns, tend to be surprisingly killable. Wouldn’t be it a shame if that Lovecraftian Horror slaughtered all the gods after eating the weave? If we want to be self-sufficient, we can’t rely on other people to grant us their power.

4. Artifacts

So, all that’s left to bypass physical damage immunity in the case of an Apocalyptic event that includes the destruction of the Weave, as well as any and all Gods, are Artifacts. They’re also incredibly rare, and we might never be able to find one. Especially if there’s an evil cult that, inspired by the magic-devouring Aberration from the far realms, seeks out to steal and destroy all Artifacts in existence? We can bet that our evil, evil DM will find a way to steal our Artifact Sword. In fact, he might take a page out of the Tomb of Horrors and teleport us into a danger zone while teleporting all of our equipment faaaar away! So, we can’t rely on any external items, because they WILL get stolen. Unless we have a 100% surefire way to prevent Artifacts from being stolen or destroyed…

5. Food, Water, Air and Aging

Living things tend to need these things to survive. But what if all the Gods are dead, and we’re stuck in a magic-devoid outer space for 10’000 years? Thankfully, this is an easy fix: be a Warforged! No need for food, water, or even air. You also technically don’t age, but take that Immortality Boon just in case you might start to rust.

*6. Sleep *

We don’t want to sleep, ever. It’s like begging our Evil DM to send assassins and/or thieves. Thankfully, Warforged remain fully conscious during their rest, so that problem’s solved.

7. Getting Lost.

Take the wanderer background ability. If magic doesn’t exist anymore, it can’t make you get lost.

What Class?

Here’s my analysis on potentially useful classes. Remember, we ideally want to be able to kill any monster in the game without having to rely on items, the weave, or the Gods not being dead. This section will also contain the questions I’m most curious about:


Potential to attune to 6 Artifacts at once, or perhaps even craft your own Artifacts. But I don’t think they have a way to prevent their items from being stolen/teleported away?


Ancestral Guardian Barbs can deal non-magic Force Damage, but only when they protect other creatures. We can’t rely on always having another creature handy.

Do Zealot Barbarians lose their Divine Fury ability if their God Dies? Does Divine power still exist if all gods die? Do they even need a God? If they can still do the radiant damage without needing any Gods, then they’re amazing. Rage Beyond Death, paired with stacking the Epic Boon that lets you recover half of your max HP, will allow you to fight for days on end. Or more, depending on how many epic boons you stacked.


I doubt Bards will be very helpful without the Weave.


Without their Gods, they’re useless. Did i miss anything?


Wildshape is suppressed in Antimagic Field. I don’t think Druids can do anything without the Weave.


Eldritch Knights have the Weapon Bond Ability, which seems to be able to work with Artifacts! So, if you can find an Artifact weapon that’s hard to destroy (unlike the Sword of Zar***), this might be great for always having a viable weapon on hand. Provided you can get one in the first place.


Fluff text implies that Ki uses the Weave, so bye-bye Monk.


Now, this depends: If we can have a Paladin that is empowered entirely by their Oath and cause, without needing any God, this might be perfect. The question is: without the Weave or Gods, would a Oath of Redemption Paladin still retain some of their non-magic abilities, such as Aura of Protection, Improved Divine Smite, Protective Spirit and Emissary of Redemption? If yes, this might be a clear winner. If no, too bad.


A Horizon Walker Ranger has the "Planar Warrior" ability, which grants them mobility and a decent chunk of force damage – perfect, as the only monsters immune to force damage aren’t immune to nonmagical damage. It also draws on "the energy on the multiverse", which seems absolutely omnipresent to me. Unless there’s some Far Realms shenanigans involved, maybe.


The Soulknife has A wellspring of psionic energy within you. I’m not sure if this mean they can use their psychic blades without the weave, given that psionics in general seems to be another form of weave-related magic in 5e. Psychic damage also isn’t as reliable as radiant or force.

The Phantom subclass can do extra Necrotic damage via to power of souls, but this isn’t a reliable enough damage type: what if I need to kill a demilich?

Sorcerer, Warlock and Wizard

All of these seem to be absolutely reliant on the weave/ their patrons being alive to do anything relevant. Of course, tell me if i missed something


Whew, this has become quite the wall of text, hasn’t it? Anyways, I wanted to ask you, fellow theorycrafter, to answer my questions under the "Classes" section, as well as help me find any further things i might have missed: anything to find the theoretical perfect character that can reliably make it through any circumstances.

What is the most Cantrips a player can learn?

Pretty much just the title, within the following restrictions:

  • Multiclassing approved
  • 20th level
  • only official material (No unearthed arcana, but anything optional material from TCoE that might effect cantrips is okay)
  • All cantrips must be unique (a Cleric 1/Bard 1 knows 5 cantrips, but they must be 5 different cantrips)
  • Magic items that provide a specific cantrip are okay, but no boons that can be continually stacked.
  • Feats are Okay.

WooCommerce – Get 10 Most Sold Products

I am trying to display the 10 most sold products on my website but I am not getting the right products. I am using the following code in order to get the relevant products:

$  query = new WP_Query(array(     'post_type'           => 'product',     'post_status'         => 'publish',     'posts_per_page'      => 10,     'meta_key'            => 'total_sales',     'orderby'             => 'meta_value_num',     'order'               => 'DESC', )); 

When I check in WooCommerce --> Reports --> Orders --> By Product, it displays 10 different products than the products I get using the above code.

So I did a little experiment and using the following code I am printing the amount a product is sold:

echo "total_sales: " . get_post_meta( $  product_id, 'total_sales', true ) . "<br>"; 

This code returns a different value then the value in WooCommerce --> Reports --> Orders --> By Product. For example, I have a product with an id 555565 and in WooCommerce --> Reports --> Orders --> By Product it says there are 47 sales of this product while get_post_meta( $ product_id, 'total_sales', true ) returns 3.

Also I am using the following code (which I found on StackOverflow) in order to print all the orders which includes product 555565 and it turns out the product is included in 43 orders:

function get_orders_ids_by_product_id( $  product_id, $  order_status = array( 'wc-completed' ) ){ global $  wpdb;  $  results = $  wpdb->get_col("     SELECT order_items.order_id     FROM {$  wpdb->prefix}woocommerce_order_items as order_items     LEFT JOIN {$  wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id     LEFT JOIN {$  wpdb->posts} AS posts ON order_items.order_id = posts.ID     WHERE posts.post_type = 'shop_order'     AND posts.post_status IN ( '" . implode( "','", $  order_status ) . "' )     AND order_items.order_item_type = 'line_item'     AND order_item_meta.meta_key = '_product_id'     AND order_item_meta.meta_value = '$  product_id' ");  return $  results; 


##To conclude##

I suspect something wrong with total_sales. If someone knows how to solve it, I will be grateful 🙂

If any more information is needed, please let me know and I will add it.