pva
30-07-2014, 10:42
Всем привет! Проконсультируйте, пожалуйста (если кто знает внутреннее устройство разных БД)
Мне нужно установить зависимости между разными (именно!) строками. Варианты решения:
1)
create table Groups(parent varchar(255), child varchar(255))
create index Groups_parent_index on table Groups using hash parent
create index Groups_child_index on table Groups using hash child
2)
create table Groups(id integer not null primary key, name varchar(255) unique)
create table Group_kids(parent integer references Groups(id), child integer references Groups(id))
create index Groups_parent_index on table Groups using hash parent
create index Groups_child_index on table Groups using hash child
Может ли вариант (1) догадаться не хранить дубликаты строк? Или предпочтительней вариант (2)?
Средняя длина строки 40 символов, на одну группу в среднем приходится 20 дочерей. Групп около 500, предаствляют по структуре однонаправленный граф (не дерево).
Мне нужно установить зависимости между разными (именно!) строками. Варианты решения:
1)
create table Groups(parent varchar(255), child varchar(255))
create index Groups_parent_index on table Groups using hash parent
create index Groups_child_index on table Groups using hash child
2)
create table Groups(id integer not null primary key, name varchar(255) unique)
create table Group_kids(parent integer references Groups(id), child integer references Groups(id))
create index Groups_parent_index on table Groups using hash parent
create index Groups_child_index on table Groups using hash child
Может ли вариант (1) догадаться не хранить дубликаты строк? Или предпочтительней вариант (2)?
Средняя длина строки 40 символов, на одну группу в среднем приходится 20 дочерей. Групп около 500, предаствляют по структуре однонаправленный граф (не дерево).