Question: In postgreSQL how would i make these two tables have a relationship between each other i tried with the foreign key but that does not

In postgreSQL how would i make these two tables have a relationship between each other i tried with the foreign key but that does not work

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

CREATE TABLE bank_account( id SERIAL, account_number INTEGER PRIMARY KEY, account_balance INTEGER, CONSTRAINT bank_users FOREIGN KEY (id) REFERENCES accounts(id) ON DELETE CASCADE );

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

INSERT INTO bank_account( account_number, account_balance) VALUES ('1234', '50000'),('4332', '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!