Link to home
Start Free TrialLog in
Avatar of chuckmullins
chuckmullinsFlag for United States of America

asked on

How to create table with combo primary key which are also two foreign keys

I'm creating a bridge table to change a many to many relationship to two many to one relationships.
I'm new to transact-sql.  The create table statement below references two columns for the primary key, au_id and title_id.  These are also both primary keys in two other tables, called authors and titles.  I'm not sure I have the syntax correct below.  Any suggestions, oberservations are appreciated.

create table titleauthor (
au_id VARCHAR (7) NOT NULL,
title_id VARCHAR (7) NOT NULL,
royalty FLOAT,
notes TEXT,
PRIMARY KEY (au_id,title_id),
FOREIGN KEY (au_id,title_id) REFERENCES authors,titles);
ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chuckmullins

ASKER

Perfect!  Thanks so much!