spring official batch table relationship description seems wrong - spring-batch

The first thing I'd like to say is that I'm not a database expert.
I found something wrong that the structure of the batch table described in the following link.
https://docs.spring.io/spring-batch/docs/3.0.x/reference/html/metaDataSchema.html
batch table relationship
The BATCH_JOB_INSTANCE and BATCH_JOB_EXECUTION tables, /BATCH_JOB_EXECUTION and BATCH_STEP_EXECUTION tables have a non-identifying, one-to-many relationship that matches the content described in the below MySQL SQL link.
https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql
But isn't it correct that the BATCH_JOB_EXECUTION and BATCH_JOB_EXECUTION_CONTEXT tables must have a one-to-one relationship? (BATCH_STEP_EXECUTION and BATCH_STEP_EXECUTION_CONTEXT too)
And I don't understand why BATCH_JOB_EXECUTION_PARAMS does not have primary key.
I humbly believe that this drawing must have been drawn by a professional
and that if many people saw this drawing and did not correct it, I would be wrong.
I created tables using schema-mysql.sql and get the picture drawing by other CASE tool,
It displays one-to-one relationship.
Is this wrong or am I?

isn't it correct that the BATCH_JOB_EXECUTION and BATCH_JOB_EXECUTION_CONTEXT tables must have a one-to-one relationship?
Each job execution has its own execution context, and an execution context belongs to a single job execution. So the relation should be one-to-one. The same is true for a step execution. The diagram should be updated. Please open an issue with a reference to this SO question and we will fix it.
And I don't understand why BATCH_JOB_EXECUTION_PARAMS does not have primary key.
This is because job parameters have no identity, they are value objects. Therefore, the table does not have a primary key, but you can add one if you want. This won't alter the internal behaviour of the framework. This is explained in the appendix here.

Related

progress 4gl: how link two database with foreign key relationship

How to link two databases in progress 4gl with foreign key relationship?
FOR EACH jeld-wen.customer :
FIND FIRST adm2.order WHERE adm2.order.custnum = jeld-wen.customer.custnum NO-LOCK NO-ERROR.
IF AVAIL adm2.order THEN
DISP jeld-wen.customer.custnum adm2.order.custnum adm2.order.ordernum.
END
Progress has no "foreign key" support like you might find in some SQL databases. Relationships are maintained by application code similar to what you have shown.
Rule #1 - Progress is not SQL.
I cannot see a question in here although I assume you would not get the expected result from the query you have run.
The best thing you could do is refer the Data Dictionary for indexes and table relations it would give you a clear idea about the design of the Database and how are they related. In there you would find the relationship quite similar to 'foreign key relationship' in SQL if there is any.
Example Pregress DB:
Member Table Event Table
> memberid eventid
> memberstatus memberid
> memberpayno eventstatus
If you consider above example, memberid would be the foreign key equivalent in SQL.

EF many to many with junction entity database first

I have a junction table with and idenity primary key columns to realize a many to many relationship. Visual Studio automatically detects it as a many to many relationship and the junction table is not an entity.
How can i realize it that also this table is generated as an entity? I need this for breeze.js .
You just need to add additional columns (or properties) to that table (or model).
You said that your table has acolumn named ID and it's the primary key withe IsIdentity set to true. It must works, I'm using this approach...
There must be a problem or missing with your table definition. However, if all are OK, just add a nullable column in your table and update your model from database. The problem will go away.

EF db first and table without key

I am trying to use Entity Framework DB first to do quick prototyping of a reporting website for a huge db. The problem is one of the tables doesn't have a key. I got an 'Error 159: EntityType has no key defined'. If I add a key on the model designer, I got 'Error 3024: Must specify mapping for all key properties'. My question is whether there is a way to workaround this WITHOUT adding a key to the table. The table is not in our control.
Huge table which does not have a key? It would not be possible for you or for table owner to search for anything in this table without using full table scan. Also, it is basically impossible to use UPDATE by single row without having primary key.
You really have to either create synthetic key, or ask owner to do that. As a workaround, you might be able to find some existing column (or 2-3 columns) which is unique enough that it can be used as unique key. If it is unique but does not have actual index created, that would be still not good for performance - you should create such index.

MySQL Workbench... Populating the fk column

I'm brand new to MySQL Workbench and a have a bit of experience with databases (MS Access). I'm having trouble populating my fk with data. Here's what I have in my db schema:
2 tables Block and Set (Block having a pk Block_ID (type of INT); Set having fk to Block with fk name Set_Block_ID (type of INT).
1 to many relationship created from Block to Set tables linking Block_ID to Set_Block_ID. Relationship created, no problems
I populate the Block table with data. No problems
I then go to populate the Set table with data. I can see all my columns but not the fk. My question is why?
I have created the exact same db in MS Access and my fk is displayed in the linked table and I can populate it while MS Access makes sure referential integrity is enforced. I'm really brand new to Workbench and cant figure out why I cant see and populate my fk column.
Any help is appreciated!
Thanks!! =)
After having digested all the replies to my question (note sarcasm here) I have finally found a workaround way of solving the issue. To recap:
ISSUE:
created a simple 2 table relationship with Workbench with PK and FK (1 .. n relationship)
FK column not visible in Table Edit so not possible to enter any referencing data
SOLUTION:
installed SQLyog and connected to same server
opened same database and redid the simple 1 .. n relationship
FK column visible for editing in SQLyog
likewise, FK column visible for editing in Workbench
As I said, I'm new to this whole thing so I don't know what the problem was in Workbench. I just know it seems to be working fine now.
As you have noticed, the relationship drawing tool does not create actual foreign key constraints.
However, if double-click the referencing table and switch to the foreign-key tab, you can create references and specify the columns involved. This generates and maintains the visual linkage automatically:

Problem in mapping fragments in Entity Framework

I am using Entity Framework and I ran into an odd build error.
I am building a forum and I set up a table in the database for "ignores" when people don't like each other they will ignore someone. The table has two columns and together they are the primary keys.
PK InitiatingUser
PK IgnoredUser
When EF maps this table I get this error:
Error 7 Error 3034: Problem in mapping fragments starting at lines 1467, 1477:Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.
I opened up the edmx in the XML editor and navigated to the offending lines.
<MappingFragment StoreEntitySet="Ignores">
<ScalarProperty Name="IgnoredUser" ColumnName="IgnoredUser" />
<ScalarProperty Name="InitiatingUser" ColumnName="InitiatingUser" />
</MappingFragment>
I am just getting started with EF and I don't understand what is going on or what the issue might be.
Edit
The relationships between ignores used to have foreign keys mapping both initiating user and ignored user to the primary key (username) of users table. That was how it was when I first mapped EF to this table. I have since deleted the FKs to see if that would help but it didn't.
This is likely due to including a many-to-many join table in your entity model, or what EF thinks is such a table (possibly such as one that doesn't have its own self-contained key, but whose identity is made up of two or more foreign keys).
So, for example, let's say you have the following tables:
Person
Address
PersonAddress (contains only PersonID and AddressID)
In your entity model, you should only add Person and Address. If you add PersonAddress, then EF will throw the error. According to this MSDN Q&A, EF will take the join table into account automatically.
I don't know what was wrong here, but I just deleted the table from the ORM and the DB then recreated it with an actual ID column, instead of two primary keys. I re-mapped the table, compiled, and all is well now. It would have been convenient to do it the way I had it, but oh well.
If anyone has any insight let me know. I'd rather accept someone else's answer.
PK InitiatingUser;
PK IgnoredUser
two primary key cannot allow edmx file.so create sno column in that table and make that as primary key . remove the pk of InitiatingUser and IgnoredUser.
now in that two column there is no primary key available.
like
Pk sno;
FK InitiatingUser;
FK IgnoredUser