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.

Composite FK referencing PK + non unique attribute

I am trying to create the following tables in Postgres 13.3:

CREATE TABLE IF NOT EXISTS accounts (     account_id Integer PRIMARY KEY NOT NULL );  CREATE TABLE IF NOT EXISTS users (     user_id Integer PRIMARY KEY NOT NULL,     account_id Integer NOT NULL REFERENCES accounts(account_id) ON DELETE CASCADE );  CREATE TABLE IF NOT EXISTS calendars (     calendar_id Integer PRIMARY KEY NOT NULL,     user_id Integer NOT NULL,     account_id Integer NOT NULL,     FOREIGN KEY (user_id, account_id) REFERENCES users(user_id, account_id) ON DELETE CASCADE ); 

But I get the following error when creating the calendars table:

ERROR:  there is no unique constraint matching given keys for referenced table "users" 

Which does not make much sense to me since the foreign key contains the user_id which is the PK of the users table and therefore also has a uniqueness constraint. If I add an explicit uniqueness constraint on the combined user_id and account_id like so:

ALTER TABLE users ADD UNIQUE (user_id, account_id); 

Then I am able to create the calendars table. This unique constraint seems unnecessary to me as user_id is already unique. Can someone please explain to me what I am missing here?

Elementor + W3C Validator: “Attribute alt not allowed on element div at this point” for all photo gallery items [closed]

I am trying to validate my Elementor-built website using W3C Validator ( but when it comes for a page containing a photo gallery (Elementor Gallery Pro widget), I get the error:

Error: Attribute alt not allowed on element div at this point.

Obviously, Elementor applies the alt attribute to the div containing the image rather than the image itself, so this error is produced.

Any ideas how to fix it?

Thanks in advance!

Update UI when pushing new object to an array attribute

In one of my blocks I’m using an array of cards so that a user can add multiple cards to a block without having to use nested blocks and complicate the HTML.

The attributes look like this:

attributes: {     cards: {         type: 'array',         source: 'query',         selector: '.staff-list-item',         default: [],         query: {             name: {                 type: 'array',                 source: 'children',                 selector: 'h3',                 default: 'Enter name.',             },             title: {                 type: 'array',                 source: 'children',                 selector: 'p',                 default: 'Enter title.',             },             mediaID: {                 type: 'number',                 source: 'attribute',                 attribute: 'data-id',                 selector: 'img',             },             mediaURL: {                 type: 'string',                 source: 'attribute',                 attribute: 'src',                 selector: 'img',             },         },     }, } 

I then have a button component that can add one of these cards:

el(components.Button, { className: 'button button-large', onClick: onAddCard }, 'Add Card') 

And the function it calls is:

function onAddCard() {     return{         name: 'Enter name.',         title: 'Enter title.'     }) } 

So I basically push a new object into the cards… however what I’ve found is that even though I’m returning the objects… it doesn’t update the UI until I click OUT of the block… how can I get it to work similar to setAttributes?

I even tried:{     name: 'Enter name.',     title: 'Enter title.' })  return props.setAttributes( {     cards: }); 

How to limit PostgreSQL INSERTs to assure that the caller has an attribute conistent with the parent table?

In the parent table, there is a column that defines the ‘owner’ of the row. When inserting into the child, the caller provides an owner id or ‘%’, to indicate that the the caller is the administrator. I was expecting the insert with this check to be slower that a straight insert, but I didn’t expect a 70x penalty. Can you give me some ideas for how to optimize the performance to achieve the same result as this statement?

INSERT INTO child (parent_key, value1, value2)   SELECT $  1, $  2, $  3 FROM parent      WHERE parent_key = $  1       AND owner LIKE $  4     LIMIT 1; 

Table definitions:

CREATE TABLE parent (   parent_key VARCHAR(255) PRIMARY KEY,    owner VARCHAR(255) );  CREATE TABLE child (   child_key SERIAL PRIMARY KEY,    parent_key VARCHAR(255) REFERENCES parent,    value1 VARCHAR(255),    value2 VARCHAR(255) ); 

I ran an explain on my statement, and this is what I see.

 Insert on child  (cost=0.42..8.46 rows=1 width=1670)    ->  Subquery Scan on "*SELECT*"  (cost=0.42..8.46 rows=1 width=1670)          ->  Limit  (cost=0.42..8.44 rows=1 width=296)                ->  Index Scan using parent_pkey on parent  (cost=0.42..8.44 rows=1 width=296)                      Index Cond: ((parent_key)::text = '111'::text)                      Filter: ((owner)::text ~~ '%'::text) 

Since parent_pkey is a unique index, I would expect the LIKE filter to contribute an insignificant amount to the execution time. This conditional INSERT takes >70 times as long as an INSERT of VALUES. What would be a more efficient way of enforcing this constraint?

I want to get the value of a select attribute in the checkout page, and then use it to show or not the delivery data

I want to get the value of a select attribute in the checkout page on WooCommerce, and then use it to show or not the delivery data.

I have tried everything but it still does not appear, the object of my products when I go through it comes out empty.

I have tried something similar to this to see what data I am getting but it comes out empty:

add_filter( 'woocommerce_cart_item_name', 'cart_variation_description', 20, 3); function cart_variation_description( $  name, $  cart_item, $  cart_item_key ) {     // Get the corresponding WC_Product     $  product_item = $  cart_item['data'];      if(!empty($  product_item) && $  product_item->is_type( 'variation' ) ) {         // WC 3+ compatibility         //$  descrition = $  product_item->get_description();         //$  descrition = $  product_item->get_attribute( 'pa_modo' );         $  descrition = $  product_item->get_post_meta( $  variation->ID, 'price_1_50', true );         $  result = __( 'Description: ', 'woocommerce' ) . $  descrition;         return $  name . '<br>' . $  result;     } else         return $  name; } 

Thanks a lot.

Create DB snapshot without specifying the FILENAME attribute

I create DB snapshot as one of the tasks in SSIS package. The package works with 20 different DBs. Thus, each DB will have a snapshot with hard-coded FILENAME attribute.

CREATE DATABASE Sales_snap ON   (    NAME = SalesData,    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\data\' ),   (    NAME = SalesData1,    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\data\' ),   (    NAME = SalesData2,    FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\mssql\data\' )  AS SNAPSHOT OF Sales  

Is there a way to use some default path for FILENAME instead of copy-pasting the same string 20 x 3 times? Alternatively, is there any way to specify base path only once and then reuse it in other SSIS tasks?