How to implement referential integrity here?

I got the following structure – which I admit is not ideal, but so much is built on that, tat I want to minimize changes.
I am not sure about how to properly implement referential integrity between Documents and Delivery Adresses. Can it be done here without using triggers ? The problem is that the addressNum can sometimes be Null in the Documents.

CREATE TABLE [dbo].[Clients](
    [IdClient] [varchar](10) NOT NULL,
    [Nom] [varchar](40) NULL

CREATE TABLE [dbo].[ClientsDelivAdr](
    [IdClient] [varchar](10) NOT NULL,
    [AdrNum] [tinyint] NOT NULL,
    [Adresse] [varchar](200) NULL
 CONSTRAINT [PK_ClientsAdrLivr] PRIMARY KEY (IdClient, AdrNum))

CREATE TABLE [dbo].[Documents](
    [DocID] [int] IDENTITY(1,1) NOT NULL,
    [NoDoc] [char](9) NULL,
    [IdClient] [varchar](10) NULL,
    [AdrNum] [tinyint] NULL,
    [DateDoc] [smalldatetime] NOT NULL,

Some Clients have several Delivery Adresses, some have none.
So data looks like this:

  • What is the comparative speed of temporary tables to physical tables in SQL?
  • Consolidate SQL Server databases into 1
  • Installing SQL Server 2014 Express package as ClickOnce prerequisite
  • MSSQL Data type conversion
  • Running 'SET' command in SQL, prior to SELECT
  • Best practice for SQL Server 2008 schema change
  • Clients
    Id   Name     Address 
    ---  ----     -------
    AA   ClientA  addressA
    BB   ClientB  qddressB
    CC   ClientC  addressC
    Client  Adr   Address
    ------  ---   -------
    AA      1     shop1
    AA      2     shop2
    CC      1     shopx
    DocId   Client  Addr  OrderDate
    ------- ------  ----  --------
    1001    CC      1     5/5/2013
    1002    AA      1     5/5/2013
    1003    BB     (Null) 5/5/2013

  • T-Sql function to convert a varchar - in this instance someone's name - from upper to title case?
  • deferred constraint checking
  • Downloading a file after storing it in SQL Server 2008 Data Base
  • make EF map byte array to binary instead of varbinary
  • Dynamic Insert in SQL without Field Names
  • SQL Finding the size of query result
  • One Solution collect form web for “How to implement referential integrity here?”

    I think you can just use foreign keys as you would expect:

    CREATE TABLE [dbo].[Documents](
        [DocID] [int] IDENTITY(1,1) NOT NULL,
        [NoDoc] [char](9) NULL,
        [IdClient] [varchar](10) NULL,
        [AdrNum] [tinyint] NULL,
        [DateDoc] [smalldatetime] NOT NULL,
         references Clients (IdClient),
    CONSTRAINT FK_Doc_Addresses FOREIGN KEY (IdClient,AdrNum)
         references DeliveryAddresses (IdClient,AdrNum) ) 

    If one or more column values in the referencing side of a foreign key is NULL, then the foreign key constraint is not checked. Conversely, there’s no way to have NULL be a foreign key reference.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.