I'm trying to create to link two tables together with a bridge table in MariaDB.
(我正在尝试在MariaDB中创建将两个表与一个桥表链接在一起的方法。)
The table itself is called 'ActsIn' and is between the 'Actors' and 'Movies' tables. (该表本身称为“ ActsIn”,位于“ Actors”和“ Movies”表之间。)
In my ER diagram, the 'ActsIn' table consists of 3 attributes-
(在我的ER图中,“ ActsIn”表由3个属性组成-)
- The Primary Key for the 'ActsIn' table which is a composite primary key made up of the two foreign keys below.
(“ ActsIn”表的主键是由下面的两个外键组成的复合主键。)
- ActorName (A foreign key referencing the primary key in the 'Actors' table)
(ActorName(引用“ Actors”表中主键的外键))
- Title (A foreign key referencing the primary key in the 'Movies' table)
(标题(引用“电影”表中主键的外键))
When I'm creating this table in MariaDB, do I treat the composite primary key as an attribute in its own right named ActorName/Title?
(当我在MariaDB中创建此表时,是否将复合主键作为其本身名为ActorName / Title的属性来对待?)
//Create table ActsIn
//
CREATE TABLE IF NOT EXISTS ActsIn (
ActorName/Title VARCHAR(255) NOT NULL,
ActorName VARCHAR(255) NOT NULL,
Title VARCHAR(255) NOT NULL,
PRIMARY KEY (ActorName/Title)
);
Or make the 2 attribute fields ActorName and Title and then create a primary key referencing both of these attributes?
(还是在2个属性字段中定义ActorName和Title,然后创建引用这两个属性的主键?)
CREATE TABLE IF NOT EXISTS ActsIn (
ActorName VARCHAR(255) NOT NULL,
Title VARCHAR(255),
PRIMARY KEY (ActorName, Title)
);
ask by Goselnator translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…