Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » Compound foreign keys in linking tables (Can I create a LINK1 between two tables where one or both of the tables have compound primary keys?)
Compound foreign keys in linking tables [message #4930] Tue, 25 August 2015 21:24 Go to previous message
rafs is currently offline  rafs
Messages: 69
Registered: May 2015
Member
Given the tables and relationships below, can you explain how to make the LINK1 relationship work from books to audiences?
I tried by defining a CALCULATED parent field for book to book_audiences with calculated field of CONCAT(book_type, ' ', book_name) AS book_type_name.
It gave me an SQL error.
I also tried with just using book_type as the parent field, unsuccessfully.

Is this possible? I don't see any examples of compound keys in linking tables in your demos.

CREATE TABLE book (
book_type char(3),
book_name character varying(100),
book_desc character varying(1000),
PRIMARY KEY (book_type, book_name)
);

CREATE TABLE audience (
aud_type char(3),
aud_name character varying(100),
aud_desc character varying(1000),
PRIMARY KEY (aud_type, aud_name)
);

CREATE TABLE book_audience (
book_type char(3),
book_name character varying(100),
aud_type char(3),
aud_name character varying(100),
PRIMARY KEY (book_type, book_name, aud_type, aud_name),
FOREIGN KEY (book_type, book_name) references book (book_type, book_name),
FOREIGN KEY (aud_type, aud_name) references audience (aud_type, aud_name)
);



Thanks.

[Updated on: Tue, 25 August 2015 21:24]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Choose null on add3 popup
Next Topic: How to provide choices for two compound foreign keys in a form?
Goto Forum:
  


Current Time: Tue Nov 26 05:17:44 EST 2024

Total time taken to generate the page: 0.00946 seconds