When adding a new record to players Entity I want to check if the national number is

hello

i have entity "people" and attribute "national number"

and i have another entity "players" and attribute "national number"

When adding a new record to players Entity
I want to check if the national number is in people Entity

regards

Hi Rashed,


Maybe, let's first ask : how have you modeled the player and people entities?  Do all players in your database also have a record in your people entity.  So you record some general stuff like name, address, birthdate, national number in the people entity, and then some additional player information like maybe skills, left or right, certificates, injuries, ... in the player entity.

If that is your intention, and you never need to have a player record without a matching people record, then there is no need to also add things like the national number in your player entity.

If each person only has one player record, you can simply have a one-to-one relationship between people and player by having the people id as the identifying attribute of the player entity.

If a person can have many player records in your database (for example if you want a different player record per sports they play or per team they are in or ...) then use a one-to-many, with the id of people entity as reference attribute in your player entity.

When adding player information, you only need to pick the right people record this player record should refer to, and create the link by storing that id in your player record reference attribute.  

You could do that by letting the user enter the players national number (beside any number of other ways, like letting him select the person in a searchable list and then add the player info, or  ...)  So you let the user enter a national number, and then in the server action to create the player record, you will have a aggregate on people entity with that national number as filter, this aggregate will give you the id of the people record, that you can then use as the reference attribute value in the player record you are creating.  

So what should happen if no people record with that national number exists yet, will you then ask the user to first add the people record, before he can enter the player record ??   I personally think this is not a good user experience, I'd rather let them pick a person record from a list and then add extra player information to it.  If the person is not in the list, they can immediately add him and then proceed with adding the player info.

Also on a side note, I think it's better to be consistent with naming entities, so person instead of people, as player is also singular noun.


Good Luck,

Dorine

Rashed khalel wrote:

hello

i have entity "people" and attribute "national number"

and i have another entity "players" and attribute "national number"

When adding a new record to players Entity
I want to check if the national number is in people Entity

regards


Hi ,


For that use aggregate and apply the filter on the mentioned column.


Thanks

Hi,

Dorine is giving you the correct feedback.

The key here is that you store data (national number) not redundant, and at the right entity.

Of course, you can use an aggregate with your current data model to solve your problem, but the key problem is the data model that you should improve.

Regards,

Daniel

JitendraYadav wrote:

Rashed khalel wrote:

hello

i have entity "people" and attribute "national number"

and i have another entity "players" and attribute "national number"

When adding a new record to players Entity
I want to check if the national number is in people Entity

regards


Hi ,


For that use aggregate and apply the filter on the mentioned column.


Thanks


hi

i want
when add a new player
Verify that it is not in another entity
using ad-hoc or foreach

thanks