How to save the path of an image when creating a table in SQL?

Asked

Viewed 32 times

0

Hey, guys, what’s up? I have this case: I need to create a product table with the attributes 'id', 'Description', 'stock', 'unit', 'price' and 'local_photo', only I have doubts about the type of data to save the path of this photo. It would be a varchar supporting how many characters?

CREATE TABLE produto (
    id INT AUTO_INCREMENT NOT NULL,
    descricao VARCHAR (200) NOT NULL,
    estoque INT (40) NOT NULL,
    preco_venda FLOAT NOT NULL,
    unidade CHAR(2) NOT NULL,
    local_photo ??
    
    


);

  • it is better to keep the image path, and the size of the varchar will depend on where it is stored and the size of the image name.

  • A varchar of (100) will be good?

  • Have you searched the maximum path size that the OS image will be hosted supports? Most operating systems have something around 255, but you have to confirm, but deep down you need to know that. Where will the images be stored? which path? how is it varcharcan put a larger than expected size that will not use, but the problem is even know how it will be stored, discover this and will get your answer :)

  • images can both have a name and teste.png as well as teste-implantado-na-empresa-fulana-20-19-2020-11-24-30.png, still having to add the full path from where it is stored. everything depends on how your server is structured.

  • Varchar was created for this, you create with a size "good enough" and he only uses what he needs, his response depends on ...

  • The maximum size a file name may have depends on the operating system and its version, and the file system used.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.