ERD related, can you make one to one relationship with a single attribute entity to another entity?

ERD Here

So for my database project, I designed a meat supply chain optimization project for a large organization, for example such as walmart, where every part of the chain is owned by the organization, (transport, farm, retail store etc). I created an entity called Workplace with primary attribute Workplace_ID, and other attributes Type (farm, retail store, transport etc) and location. Workplace_ID is also the primary key for the other workplaces such as Slaugherhouse, Farm, Transport etc. What I intended was to do was for the other entities’ primary key to be foreign key Workplace_ID, where I could easily create new tables specifying type and workplace_ID, relating Workplace entity to for example Farm entity. I have linked the ERD diagram here so that you can see how it was designed.

The problem was, my professor didn’t even listen to my final presentation, he just saw the auto generated ERD from XAMPP, and said that we were kidding him and wasting his time with a single attribute entity (Farm) having a foreign key as primary key, with the relation being 1 to 1. He then asked us to provide one example from anywhere of such a thing existing, an ERD would serve as a valid example, implying that such a thing was impossible to find, with the implication being if we could not provide any example we would receive 0.

An important thing to note that he did not let me clarify my design choices, and that I intended it to be a IS A 1-1 relationship, sure, as in one instance of farm entity can only be one instance of workplace entity, but also that not all instances of workplace entities were instances of farm entities, it would only be instances of workplace entities which had farm as the type attribute. I designed it as such so that all workplaces did not have to include their locations and types again and again in their attributes, you would create a relationship table between two entities specifying type and Workplace_ID. I designed it in such a way since for some, Workplace_ID is primary key, whereas for others, it is simply a foreign key relating to other entities (for example, Batch has Workplace_ID signifying where the particular batch came from (which slaughterhouse), but its primary key is Batch_ID).

Could Someone please point me to any example or cite something to potentially even save my grade?

The deadline for coming up with even a single example is before my final exam, on the 30th of September. Thanks for taking the time to read, and sorry for this bother.

Custom post ID & display information related to this ID

I’m new to WordPress and I want users to be able to retrieve a post by its ID.

For that I will be using a form in the homepage asking an ID and submitting the form will redirect user to the post’s URL.

I see that as 2 steps:

  1. use dynamic permalinks
  2. display post information based on the ID (I am using CPT UI and ACF)

For step 1, I went to wp-admin/options-permalink and set it to "simple > http://.com/?p=123". Hopefully it’s the good way, correct?

For step 2, how can I retrieve the ID from the URL and display the informations related to a particular post?

  • should I edit a particular page like posts.php?
  • how to edit this page? FTP or add-on?
  • is there a way to do such thing from the UI directly?

One-row postgres query as CTE/subquery much slower when passing subquery field into function / maybe related to inlining?

I’m using postgres 13.3 with inner and outer queries that both only produce a single row (just some stats about row counts).

I can’t figure out why Query2 below is so much slower than Query1 (they should basically be almost exactly the same, maybe a few ms difference at most)…

Query1: This query takes 49 seconds:

WITH t1 AS (         SELECT             (SELECT COUNT(*) FROM racing.all_computable_xformula_bday_combos) AS all_count,             (SELECT COUNT(*) FROM racing.xday_todo_all) AS todo_count,             (SELECT COUNT(*) FROM racing.xday) AS xday_row_count         OFFSET 0 -- this is to prevent inlining )  SELECT             t1.all_count,             t1.all_count-t1.todo_count AS done_count,             t1.todo_count,             t1.xday_row_count FROM t1 

Query2: This query takes 4 minutes and 30 seconds (only one line difference):

WITH t1 AS (         SELECT             (SELECT COUNT(*) FROM racing.all_computable_xformula_bday_combos) AS all_count,             (SELECT COUNT(*) FROM racing.xday_todo_all) AS todo_count,             (SELECT COUNT(*) FROM racing.xday) AS xday_row_count         OFFSET 0 -- this is to prevent inlining )  SELECT             t1.all_count,             t1.all_count-t1.todo_count AS done_count,             t1.todo_count,             t1.xday_row_count,             -- the line below is the only difference to Query1:             util.divide_ints_and_get_percentage_string(todo_count, all_count) AS todo_percentage FROM t1 
  • Before this point, and with some extra columns in the outer the query (which should have made almost zero difference), the whole query was insanely slow, like 25 minutes, which I think was due to inlining maybe? Hence the OFFSET 0 being added into both queries (which does help a lot).
  • I’ve also been swapping between using the above CTEs vs subqueries, but with the OFFSET 0 included it doesn’t seem to make any difference.

Here’s the definitions of the functions being called in Query2:

CREATE OR REPLACE FUNCTION util.ratio_to_percentage_string(FLOAT, INTEGER) RETURNS TEXT AS $  $   BEGIN     RETURN ROUND($  1::NUMERIC * 100, $  2)::TEXT || '%'; END; $  $   LANGUAGE plpgsql IMMUTABLE;   CREATE OR REPLACE FUNCTION util.divide_ints_and_get_percentage_string(BIGINT, BIGINT) RETURNS TEXT AS $  $   BEGIN          RETURN CASE          WHEN $  2 > 0 THEN util.ratio_to_percentage_string($  1::FLOAT / $  2::FLOAT, 2)         ELSE 'divide_by_zero'          END         ;  END; $  $   LANGUAGE plpgsql IMMUTABLE; 
  • As you can see it’s a very simple function, which is only being called once, from the single row the whole thing produces… how can this cause such a massive slowdown? And why is it affecting whether postgres inlines the initial subquery/WITH (or whatever else might be going on here)

EXPLAIN ANALYZE outputs:

  • Query1: https://explain.depesz.com/s/bq7u
  • Query2: https://explain.depesz.com/s/9w3rY

Need Advice Related to WordPress Website

I have created a WordPress website namely: iccoindia.org. Recently an error started to occur, when I log in to the Wp-admin and start using the website it is working fine. But in normal case, the website is not working properly, all the pages jas become static, even if I change the page, the URL changes but the page layout remains the same.

I have disabled the plugin individually and reenabled it, still, the problem is there, I have changed the .htacess file, still, the problem is there.

I…

Need Advice Related to WordPress Website

I need to find what kind of game this is, or if theres any tutorials related to this

Hello I am having a hard time getting an answer to what type of game this is. Party In My Dorm and Kingdoms at War are both mobile games where you have a character and you build its states by either placing dormmates or buildings. Its an MMORPG in a sense but its all 2d, you attack monsters and do quests and missions but its all basically text based, there is no animations or nothing. But looking at text based rpgs they look nothing like this, so is this type of game called something else or does anyone have any idea on how to try to make a game similar to this?

Display related posts without a plugin

I’m trying to display the related posts using functions.php:

function posts_related($  related){ if (is_single()) { global $  post; // Build basic custom query arguments $  custom_query = new WP_Query( array(         'posts_per_page' => 8, // Number of related posts to display        'post__not_in' => array($  post->ID), // Ensure that the current post is not displayed        'orderby' => 'rand', // Randomize the results ));  // Run the loop and output data for the results if ( $  custom_query->have_posts() ) : while ( $  custom_query->have_posts() ) : $  custom_query->the_post();   if ( has_post_thumbnail()   ) {                   $  permalink = the_permalink();                  $  post_thumbnail = the_post_thumbnail('medium');                  $  title = the_title();                                         $  related .= '<a href="' . $  permalink .  '"><img src="' . $  post_thumbnail . '/></a>';                               }            $  related .=  '<a href="' .  $  permalink . '"><b>' . $  title . '</b></a>';      endwhile;   else :      $  related .= '<p>Nothing to show.</p>'; endif; // Reset postdata }          echo '<pre>'; var_dump( has_post_thumbnail() ); echo '</pre>';       return $  related;  }    //wp_reset_postdata();  add_filter( "the_content", "posts_related", 99 ); add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 100, 50, true ); 

But I’m not being able to handle the output properly. I need it to display below the post (single post).

Queueing MySQL record inserts to avoid over-subscription of a related resource … table locking?

Given a simplified hypothetical of seats in a lifeboat, if I have the following setup with a lifeboats table and a seats table where each record is one occupied seat in the given lifeboat:

CREATE TABLE lifeboats (   id INT UNSIGNED NOT NULL,   total_seats TINYINT UNSIGNED NOT NULL,   PRIMARY KEY (id));  INSERT INTO lifeboats (id, total_seats) VALUES (1, 3); INSERT INTO lifeboats (id, total_seats) VALUES (2, 5);  CREATE TABLE seats (   lifeboat_id INT UNSIGNED NOT NULL);  INSERT INTO seats (lifeboat_id) VALUES (1); INSERT INTO seats (lifeboat_id) VALUES (1); INSERT INTO seats (lifeboat_id) VALUES (1); INSERT INTO seats (lifeboat_id) VALUES (2); 

I can find lifeboats with available seats by querying:

SELECT      l.id, l.total_seats, COUNT(s.lifeboat_id) AS seats_taken FROM     lifeboats AS l         LEFT JOIN     seats AS s ON s.lifeboat_id = l.id GROUP BY l.id HAVING COUNT(s.lifeboat_id) < l.total_seats 

What is the best way to ensure 2 clients do not grab the last seat in a lifeboat without implementing some coordinating process queue?

My only idea (assuming I’m trying to grab seat in lifeboat 2) is going LOCK TABLE rambo like:

LOCK TABLE seats WRITE, lifeboats AS l READ, seats AS s READ;  INSERT INTO seats (lifeboat_id) SELECT      id FROM     (SELECT          l.id, l.total_seats, COUNT(s.lifeboat_id) AS seats_taken     FROM         lifeboats AS l     LEFT JOIN seats AS s ON s.lifeboat_id = l.id     WHERE l.id = 2     GROUP BY l.id     HAVING COUNT(s.lifeboat_id) < l.total_seats) AS still_available;  UNLOCK TABLES; 

but this is not very elegant, needless to say.

(My environment is MySQL8/InnoDB)

Can a Way of Astral Self Monk use wisdom related scores for jumping?

I have several questions on the interactions between the Arms of Astral Self and the Jumping mechanics. According to the 3rd level feature, Arms of the Astral Self:

While the spectral arms are present, you gain the following benefits:

  • You can use your Wisdom modifier in place of your Strength modifier when making Strength checks and Strength saving throws.
  • You can use the spectral arms to make unarmed strikes.
  • When you make an unarmed strike with the arms on your turn, your reach for it is 5 feet greater than normal.
  • The unarmed strikes you make with the arms can use your Wisdom modifier in place of your Strength or Dexterity modifier for the attack and damage rolls, and their damage type is force.

The Jumping session of the PHB states:

Long Jump

When you make a long jump, you cover a number of feet up to your Strength score if you move at least 10 feet on foot immediately before the jump. When you make a standing long jump, you can leap only half that distance. Either way, each foot you clear on the jump costs a foot of movement.

This rule assumes that the height of your jump doesn’t matter, such as a jump across a stream or chasm. At your DM’s option, you must succeed on a DC 10 Strength (Athletics) check to clear a low obstacle (no taller than a quarter of the jump’s distance), such as a hedge or low wall. Otherwise, you hit it.

High Jump

When you make a high jump, you leap into the air a number of feet equal to 3 + your Strength modifier (minimum of 0 feet) if you move at least 10 feet on foot immediately before the jump. When you make a standing high jump, you can jump only half that distance. Either way, each foot you clear on the jump costs a foot of movement. In some circumstances, your DM might allow you to make a Strength (Athletics) check to jump higher than you normally can.

You can extend your arms half your height above yourself during the jump. Thus, you can reach above you a distance equal to the height of the jump plus 1½ times your height.

My questions would be, assuming that I have Arms of the Astral Self activated:

  1. Can I use my Wisdom Score instead of my strenght score to determine my long jump distance?
  2. Can I make a Wisdom (Athletics) check instead of a Strenght (Athletics) check?
  3. Can I use my Wisdom modifier instead of my Strenght modifier to determine my high jump’s height?
  4. Can the extra 5 feet range of the Arms of Astral Self be used when accounting for "extending your arms half your height above yourself" on the high jump, making it 1½ your height + 5 feet instead of only 1½ your height?

I am aware that some of the answers to these questions are up to DM discretion, so I would like to know, if possible, what would be the RAW interpretation and also how would you rule it in your games.

In advance, I’m extremely grateful to whoever takes time to answer these 🙂

Does a PF2e spellcaster who takes multiclass dedications into other spellcasting classes, and related spellcasting feats, gain more spell slots?

Ezren is a level 10 evocation wizard, and hence would have spell slots of the following levels:

+-------------+-----------------+ | Spell level | Number of slots | +-------------+-----------------+ |           1 |               4 | |           2 |               4 | |           3 |               4 | |           4 |               4 | |           5 |               4 | +-------------+-----------------+ 

However, at level 2 Ezren took the Sorcerer multiclass dedication. At level 4 he took Basic Sorcerer Spellcasting, and Bloodline Breadth at level 8.

How many spell slots does Ezren have in a given day? Is it:

+-------------+-----------------+ | Spell level | Number of slots | +-------------+-----------------+ |           1 |               6 | |           2 |               6 | |           3 |               6 | |           4 |               4 | |           5 |               4 | +-------------+-----------------+ 

Because at level 8, spellcasting archetype feats grant an additional spell slot of first, second and third level, AND the bloodline breadth feat increases each of these by one?

Or do these sources of spell slots not stack for some reason? Coming from fifth edition, a wizard who multiclasses sorcerer still has the same number of spell slots as a pure wizard, so I’d like to clarify my understanding here.