E
E
evil0o2014-05-06 14:23:44
MySQL
evil0o, 2014-05-06 14:23:44

MySql which data type to choose for url ?

Tell me what type of data to choose for url?
and in general, did I create a one-to-one connection correctly

CREATE TABLE `g_url` (
  `id` INT NOT NULL,
  `url` TEXT NOT NULL,
  PRIMARY KEY(`id`)
);
CREATE TABLE `g_field` (
  `id` int NOT NULL,
  `title` CHAR(30),
  `description` CHAR(30),
  PRIMARY KEY(`id`),
  FOREIGN KEY (`id`) REFERENCES g_url(`id`)
)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2014-05-06
@evil0o

Why not store everything in one table, why a 1:1 relationship?
Type can choose VARCHAR - there is a limit on the length or a long TEXT.

S
Sergey Nikolaevich, 2014-05-06
@Playmore

Don't make extra connections. Make in one table and field type VARCHAR with margin (0 to 65535)

N
neol, 2014-05-06
@neol

TEXT in general should be used carefully, since queries involving BLOB / TEXT that require a temporary table always lead to the creation of a table on disk ( proof ), which obviously will not add speed to your queries.
In this case, varchar will be more than enough.

R
Rsa97, 2014-05-06
@Rsa97

For a 1-1 connection, it makes no sense at all to allocate a separate table, create a field in the main one.
The TEXT type for url is fine, just limit its length to reasonable values ​​(IE8, for example, cuts to 4121 characters).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question