Questo contenuto non è disponibile nella lingua selezionata.
7.2. Unidirectional Associations
7.2.1. Unidirectional Many-to-one Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
A unidirectional many-to-one association is the most common kind of unidirectional association.
create table Person ( personId bigint not null primary key, addressId bigint not null ) create table Address ( addressId bigint not null primary key )
create table Person ( personId bigint not null primary key, addressId bigint not null )
create table Address ( addressId bigint not null primary key )
7.2.2. Unidirectional One-to-one Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
A unidirectional one-to-one association on a foreign key is almost identical. The only difference is the column unique constraint.
create table Person ( personId bigint not null primary key, addressId bigint not null unique ) create table Address ( addressId bigint not null primary key )
create table Person ( personId bigint not null primary key, addressId bigint not null unique )
create table Address ( addressId bigint not null primary key )
A unidirectional one-to-one association on a primary key usually uses a special id generator In this example, however, we have reversed the direction of the association:
create table Person ( personId bigint not null primary key ) create table Address ( personId bigint not null primary key )
create table Person ( personId bigint not null primary key )
create table Address ( personId bigint not null primary key )
7.2.3. Unidirectional One-to-many Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended.
create table Person ( personId bigint not null primary key ) create table Address ( addressId bigint not null primary key, personId bigint not null )
create table Person ( personId bigint not null primary key )
create table Address ( addressId bigint not null primary key, personId bigint not null )
You should instead use a join table for this kind of association.