I have a tables:
CREATE TABLE test_part1 (
Prefix ENUM('A','B') NOT NULL,
Unique_number int(11) NOT NULL,
Data_set1 decimal(5,2),
PRIMARY KEY (Prefix, Unique_number)
) ;
CREATE TABLE test_part2 (
composite_foregin_key tinytxt(12) NOT NULL,
Data1 varchar (11),
Data2 varchar (11)
) ;
How can I reference composite key from “test_part1” in table “test_part2” as the foreign key?
Do I need to create 2 columns called fkPrefix and fkUnique_number and use the same data types or can I create one column called composite_foregin_key?
If option with composite_foregin_key is possible, do I need to change data type of composite key to Prefix txt (1) and Unique_ number txt (11) as the composite_foregin_key would be txt (12)?
It is very important to me to join Prefix and Unique_number together as item under Unique_number is stored in either condition A or B and when referenced Prefix and Unique_ number are always together.
I am trying to learn as much as possible about computer science but it’s not my field of expertise and before working on this project I was involved in basic db architecture really long time ago. Please be understanding if my question doesn’t make any sense. I will try to phrase it other way if needed.