Question: in postgresSQL im trying to create a foreign key that links the first_name to the balance in the bank table DROP TABLE IF EXISTS accounts;

in postgresSQL im trying to create a foreign key that links the first_name to the balance in the bank table

DROP TABLE IF EXISTS accounts; DROP TABLE IF EXISTS bank;

CREATE TABLE accounts ( id SERIAL, first_name VARCHAR(50) PRIMARY KEY, last_name VARCHAR (50), email VARCHAR (50), password VARCHAR (50), account_Type VARCHAR (10), bday VARCHAR (50) );

INSERT INTO accounts ( first_name, last_name, email, password, account_Type, bday) VALUES ('bob', 'john', 'bob@gmal.com', 'bob1','Manager', '01/01/1985'), ('Tom', 'lin', 'tom@gmal.com', 'tom1', 'Manager', '5/23/1990');

CREATE TABLE bank( balance VARCHAR(20) REFERENCES accounts(first_name) );

INSERT INTO bank( balance) VALUES ('50000'),('100000');

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!