Hello, I'm new to SQL and MySQL, I'm developing a web application (php) and I need some tables relationed between them with a foreing key. The idea is the following
create table persons ( cid smallint auto_increment not null unique, name varchar(30), alias varchar(10), primary key (cid)); create table phones( pid smallint auto_increment not null unique, cid smallint not null, phone varchar(10), obs varchar(40), primary key (pid)); There are many other tables like phones and I will need to do with them the same thinks. The questions are the followings: - How do I preserve integrity? I mean, I don't want to have phones without persons, so when I delete a person I want to make a cascade erase. - When I do a: select * from persons left join phones using (cid); I get as many rows as phones have this person, is there any way to make a query that returns a single row with all the information. Those are the first, hope can you help me. Greeting, Jorge Calas Havana University.