0

I'm working on my first project and got question about drawing database (MySQL).

In my db-construction main product info table got connections with categories and image tables via foreign keys, so I can't figure out how to connect few images in 1 table slot with another. I think about cloud-system image import, so I'm using varchar datatype, but there's problem with URL length. I want use 3-4 images in one table slot.

Here's my code:

create table images (
    img_id bigint not null auto_increment,
    bigimg_url varchar(255) null,
    coverimg_url varchar(255) null,
    primary key (img_id)
)engine=innoDB;

And here my main product info table:

create TABLE product(
    img_id bigint,
    cat_id bigint,
    game_id bigint auto_increment not null,
    gameName varchar(50) null,
    gameDesc varchar(50) null,
    price DECIMAL not null,
    primary key (game_id),
    foreign key (cat_id) references categories(cat_id),
    foreign key (img_id) references images(img_id)
)ENGINE=innoDB;
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
edgarm
  • 1
  • 1
  • 1) Please do not ask multiple questions in a post, no matter how related those you think are. 2) I do not understand at all the 2nd question. Please ask that question separately in a new question with lot more explanation why a foreign key is not good enough for you to link two tables. – Shadow Feb 08 '23 at 11:40

0 Answers0