Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CREATE TABLE rate ( current_interest_rate Decimal (3,2) NOT NULL, account_type C

ID: 3831909 • Letter: C

Question

CREATE TABLE rate (

current_interest_rate Decimal (3,2) NOT NULL,
account_type Char (50) NOT NULL ,   
PRIMARY KEY (current_interest_rate, account_type)
);

CREATE TABLE accounts (

account_no Varchar(10) NOT NULL,
member_id Integer,
primary_owner_first VARCHAR(100),
primary_owner_last VARCHAR(100),
joint_owner_first VARCHAR(100),
joint_owner_last VARCHAR(100),
current_balance integer,
current_interest_rate Decimal (3,2),
account_type CHAR(50),
PRIMARY KEY (account_no),
FOREIGN KEY (current_interest_rate) REFERENCES rate (current_interest_rate),
FOREIGN KEY (account_type) REFERENCES rate (account_type)

);

For some reason I'm getting an error when I run this script, I need this exact code with these attributes, keys, and foreign keys. Can someon please help. The foreign keys in the second table (account table) wont work for some reason.

Please Help

Thanks

Explanation / Answer

Answer:

Updated query: you dont have to reference it separately, by keeping comma we can reference at once.

CREATE TABLE rate (
current_interest_rate Decimal (3,2) NOT NULL,
account_type Char (50) NOT NULL ,   
PRIMARY KEY (current_interest_rate, account_type)
);

CREATE TABLE accounts (
account_no Varchar(10) NOT NULL,
member_id Integer,
primary_owner_first VARCHAR(100),
primary_owner_last VARCHAR(100),
joint_owner_first VARCHAR(100),
joint_owner_last VARCHAR(100),
current_balance integer,
current_interest_rate Decimal (3,2),
account_type CHAR(50),
PRIMARY KEY (account_no),
FOREIGN KEY (current_interest_rate,account_type) REFERENCES rate (current_interest_rate,account_type)
);

Select * From rate
Select * From accounts

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote