您能否让一个主键引用来自不同 table 的另一个主键?如果是这样,将在什么情况或情况下使用它?

Can you have a Primary Key references another Primary Key from a different table? If so, in what case or situation would this be used?

使用主键 (customer_id) 创建一个 table,它与来自另一个 table 的另一个 PK 相匹配,并尝试引用它。

    CREATE TABLE customer_leads(
        customer_id SERIAL PRIMARY KEY, 
        first_name VARCHAR(25) NOT NULL,
        last_name VARCHAR(25) NOT NULL,
        email VARCHAR(25) NOT NULL UNIQUE,
        signup_date TIMESTAMP NOT NULL,
        duration TIME NOT NULL,
        PRIMARY KEY(customer_id) REFERENCES customer(customer_id)
        )

我认为这没有道理。它 是这样的:

CREATE TABLE customer_leads(
    customer_lead_id SERIAL PRIMARY KEY, 
    . . . 
);

CREATE TABLE customers (
    customer_id int PRIMARY KEY, 
    . . . 
    FOREIGN KEY(customer_id) REFERENCES customer_leads(customer_lead_id)
);

这个公式表示每个客户都是从客户引导开始的。 "customer_id" 被分配到潜在客户级别,其中一些最终变成了客户。

这是有道理的。外键引用来自 customers table。所有客户都有有效的线索,但并非所有线索都是(必然)有效的客户。

你的结构有问题。基本上,customer_id 是在客户线索中分配的——按序列列。那么,这应该是对另一个table的主键的引用。但是这个值是如何计算的呢?该结构对我来说没有意义。