database - Organize table avoiding redundancy -


i'm trying create database manage autobus data e/r

create table company( company_name varchar(12), tel int, primary key(company_name) );  create table line( id_line varchar(3), ncompany_name varchar(12), desc text, primary key(id_line, company_name), foreign key (company_name) references company(company_name) );  create table stop( id_stop varchar(3), geolat float(10,6), geolong float(10,6), primary key(id_stop) );  create table make( id_stop varchar(3), id_line varchar(3), hour time, primary key(id_stop,id_line), foreign key (id_stop) references stop(id_stop), foreign key (id_line) references line(id_line) ); 

the problem bus stops several times @ same stop in different hours, how store information avoiding redundancy?

for example:

id_line = 1 id_stop = 1 hour = 4:50 

than

id_line = 1 id_stop = 1 hour = 5:20 

but isn't possible, thought of adding field (autoincrement) called id didn't know if best solution. advice?

you interested in predicate "[id_line] makes stop @ [id_stop] @ time [hour]". table make defined hold rows make true. candidate key (hence primary key) (id_stop,id_line,hour) since no other subset of columns unique. diagram should include hour (according whatever diagramming conventions using). there no particular benefit id either (id_stop,id_line) pairs (which wouldn't identify rows of make, line-stop pairs ever stopped at) or (id_stop,id_line,hour) triplets.

the problem bus stops several times @ same stop in different hours, how store information avoiding redundancy?

there no such problem. subrow can appear more once in table whether or not there "redundancy". (whatever think means. although 1 can replace subrows appear multiple times ids plus table, 1 needs more joins same query result. see this answer.)


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -