postgresql – How can I have multiple foreign keys in one table?

Use an intermediary table with two columns, each being a foreign key to one of the tables.

testdb=# create table teams(team_id bigint primary key);
CREATE TABLE
testdb=# create table accounts(account_id bigint primary key);
CREATE TABLE
testdb=# create table accounts_teams(account_id bigint, team_id bigint);
CREATE TABLE
testdb=# alter table accounts_teams add constraint accounts_teams_account_id foreign key (account_id) references accounts(account_id);
ALTER TABLE
testdb=# alter table accounts_teams add constraint accounts_teams_team_id foreign key (team_id) references teams(team_id);
ALTER TABLE
testdb=# d accounts_teams
            Table "public.accounts_teams"
   Column   |  Type  | Collation | Nullable | Default 
------------+--------+-----------+----------+---------
 account_id | bigint |           |          | 
 team_id    | bigint |           |          | 
Foreign-key constraints:
    "accounts_teams_account_id" FOREIGN KEY (account_id) REFERENCES accounts(account_id)
    "accounts_teams_team_id" FOREIGN KEY (team_id) REFERENCES teams(team_id)

python – FOREIGN KEY a campos especificos en django models

estoy tratando de hacer unas tablas dinámicas en django, pero se los comento en sql para saber como lo harían ustedes

Tengo una matriz en Excel en la cual tiene etapas, procesos y campos, en este caso solo tiene que llenar los datos de campos el usuario y el admin puede crear etapas procesos y campos En esta tabla parametros se insertan todos los parametros de la matriz

tablas en sql

luego tengo una tabla temporal o de configuracion en donde contruyo la matriz que me dieron en exel, lo bueno de esta tabla configuracion si hay en un futuro cambios solo cambio la configuracion de esta tabla para dar un nuevo orden etc. entonces aqui armo la configuracion solicitada con todos los parametros

Mi pregunta está en la tabla de configuración como convierto la tabla temporal en un modelo de django, como especifico los forein key de los campos etapa_id, proceso_id y campo_id en django

alguien seria tan amable de ayudarme porfavor

database – FillPDF not displaying ‘foreign’ characters

I’m using the fillpdf module with the online FillPDF service to render the PDFs. Most everything is working great; however, if a database field I’m displaying on the PDF contains certain ‘foreign’ characters, those characters don’t display at all.

Notably, this occurs with the circumflex (ĉ) and caron (č) characters. Other foreign chars display fine (eg ö, é, è …).

Not sure if this is an issue with the FillPDF Online service or the way our database is configured. Everything displays correctly elsewhere – ie. on our website, printed documents Etc.

Anyone got any ideas?
P

usa – Can a US citizen leave and enter the US using a foreign passport?

Generally, airlines worry most about you holding a visa for the destination country. I have left the US many times forgetting to return my I-94, but I obviously had an entry record for that passport.

However, it is illegal for US citizens to enter or leave the US on another than a US passport. Since you are a US citizen, you can not obtain a US visa (for your foreign passport) and you are required to enter with your US passport (as clearly stated on the US embassy website):
https://uk.usembassy.gov/u-s-citizen-services/u-s-passports/u-s-passport-faqs/u-s-citizenship/

If you plan to re-enter the US with a foreign passport, you might get into trouble! Of course, this is up to the immigration officer, but you will already have issues boarding your flight, as the airline will check for a valid visa/ESTA with the foreign passport you plan to return with.

As a US citizen you can not obtain a visa/ESTA for your foreign passport. During the application process you will be asked if you hold or have ever held US citizenship and will therefore be refused a visa.

You can generally acquire an emergency / temporary travel document or expedite the passport application:
http://travel.state.gov/content/passports/english/passports/services/expedited.html

Is there a way to reduce or block webform submissions with foreign (non-English) content?

On Drupal 8/9 we have webforms that have been getting 5-20 spam/bot emails per day with foreign languages (looks like it may be Rusian). We have Honeypot, reCaptcha 2/3, Antibot, and Cloudflare setup but these messages still come through. I was wondering if there is a way to detect non-English characters and block the submissions?

An example of the body content of one of the submissions:

Your Message Здесь собраны лучшие рассказы русских писателей. Дети
обожают читать про приключения и веселые истории из жизни своих
сверстников, а так же про забавных животных. Смешные диалоги,
необычные сюжеты и яркие иллюстрации влюбляют в себя юных читателей с
первых страниц.

usa – Can my child enter the US on a foreign passport?

My child is entitled to US citizenship but we have been unable to register her birth abroad as due to covid we cannot get an embassy appointment. She has a valid UK passport. We need to travel to the US, will she be able to enter the US on her UK passport? She would be travelling with me (UK passport holder), my husband (US passport holder) and our other child (US passport holder).

Which visa and/or work permit do I need to enter and work in Germany as a foreign researcher? [migrated]

I accepted an offer for a three-year postdoc in Germany. It is not clear to me if I need to apply for a work permit/EU Blue Card in addition to my researcher visa. Where can I learn more? (Or do I wait for my institution to advise me on the next steps.) I don’t speak German.

azure sql database – Audit table and foreign key

I have a database with multiples tables that must be audited.

As an example, I have a table of objects defined with an unique ID, a name and a description.

The name will always be the same. It is not possible to update it. “ObjectA” will always be “ObjectA”.

As you see the name is not unique in the database but only in the logic.

The rows “from”, “to” and “creator_id” are used to audit the changes. “from” is the date of the change, “to” is the date when a new row has been added and is null when it is the latest row. “creator_id” is the ID of the user that made the change.

+----+----------+--------------+----------------------+----------------------+------------+
| id |   name   | description  |         from         |          to          | creator_id |
+----+----------+--------------+----------------------+----------------------+------------+
|  1 | ObjectA  | My object    | 2021-05-30T00:05:00Z | 2021-05-31T05:04:36Z |         18 |
|  2 | ObjectB  | My desc      | 2021-05-30T02:07:25Z | null                 |         15 |
|  3 | ObjectA  | Super object | 2021-05-31T05:04:36Z | null                 |         20 |
+----+----------+--------------+----------------------+----------------------+------------+

Now I have another table that must have a foreign key to this object table based on the “unique” object name.

+----+---------+-------------+
| id |   foo   | object_name |
+----+---------+-------------+
|  1 | blabla  | ObjectA     |
|  2 | wawawa  | ObjectB     |
+----+---------+-------------+

How can I create this link between those 2 tables ?

I already tried to create another table with a uuid and add a column “unique_identifier” in the object table. The foreign key will be then linked to this uuid table and not the object table. The issue is that I have multiple tables with this problem and I will have to create the double number of table.

It is also possible to use the object ID as the FK instead of the name but it would mean that I must update every table with that FK with the new ID when updating an object.

clean architecture – Catch “foreign” exception in adapter and convert them in own business exception is a good practice?

I am currently thinking about some design choices regarding exception handling.
My current architecture looks a little like this:

enter image description here

You can see that I have a UI where a try-catch middleware is cathing exceptions like this:

Pseudocode:

catch(CoreUserNotFoundException e)
{
   return 'You provided an invalid user id'
}
catch(CoreToLongException e)
{
   return 'The name is too long'
}
catch(Exception e)
{
   logger.log(e)
   return 'Something went wrong'
}

So only some messages will be returned to the user. All other exceptions are just logged.

Lets say someone wants to add an entity with a user id that has to be validated.
But how do I know weather the user exists or not?
This is done with my business logic. It provides an interface “IUserService” to retrieve a user. The business logic does not care how the app is doing this.
It could get the user via Graph API of Microsoft, or via Auth0 or via Facebook or whatever.
My business logic should work with all kinds of user services.

So in my picture I have a MicrosoftGraph Adapter, that implements the IUserService. This adapter is using my own Graph SDK – this SDK uses the original SDK of Microsoft, but I like my own wrapper and use it in many apps.

In my current design the “MS Graph SDK” throws an Exception if a user does not exist for an id.
This exception is bubbling through my own Graph SDK and caught in the Graph Adapter of my app.

The Graph adapter then transforms this Exception in a CoreUserNotFoundException – the one I am showing to the user:

Pseudocode:

   try {
      user = _userService.getUserById(userId);
   } catch(GraphUserNotFoundException e)
      throw new CoreUserNotFoundException("You provided a bad user id", e);
   }

Of course there are alternative ways:
I could also define an Exception in my Own Graph SDK and re-use this exception through all my projects.
But to show the user a nice message, my UI needed to have a dependency on “Own Graph SDK” because I want to do:

catch(MyOwnGraphSDKUserNotFoundException e)
{
   return 'You provided an invalid user id'
}
catch(Exception e)
{
   logger.log(e)
   return 'Something went wrong'
}

What is probably a bad practice?
In this case I would have to change the UI-code if the Adapter changes, so I am not doing it.

My questions to you:

Was my design choice correct? Or does it seem unprofessional to you?
I am still learning about clean architectures, hexagonal architectures etc., but didnt read too much about Exception handling in this topic.

mysql – Error Code: 1215. Cannot add foreign key constraint

I’m creating a DBSM on Mysql Workbench, but when Itry creating the last table i get an error because it can’t add the foreign key, but i can’t understand why since the child key has the same data type and collation as the parent key and the name isn’t repeated.

That’s the code for the two tables:

CREATE TABLE PRESTITO(
MATRICOLA_U INT,
CODICE_LIB SMALLINT(4),
DATA_P DATE,
DATA_R DATE,
N_DIP SMALLINT(2), 

PRIMARY KEY(CODICE_LIB),

FOREIGN KEY(MATRICOLA_U) REFERENCES UTENTI(MATRICOLA),
FOREIGN KEY(CODICE_LIB) REFERENCES LIBRI(CODICE_L)
);

CREATE TABLE DIPARTIMENTO(
NUMERO_DIP SMALLINT(2),
NOME_DIP VARCHAR(50) NOT NULL,
INDIRIZZO_DIP VARCHAR(50),

PRIMARY KEY(NUMERO_DIP),
FOREIGN KEY (NUMERO_DIP) REFERENCES PRESTITO(N_DIP)
);

Is there someone able to help?
Thank you very much!