On Tue, Feb 24, 2009 at 7:44 AM, Yuzem <naujnit...@gmail.com> wrote:
>
>
>
> P Kishor-3 wrote:
>> Google for "normalizing a database" and then read up on it. It will help.
>>
>
> Ok, thanks, thats the solution. Now there is another problem that arise.
> Lets say I have a table called movies with 3 columns (id, titles, keywords):
>
> 1|title1|keyword1
> 1|title1|keyword2
> 1|title1|keyword3
> 2|title2|keyword1
> 2|title2|keyword2
>
> The id column is unique, the same from imdb so if a want to add twice the
> same movie it doesn't let me.
>
> After normalization I have two tables (movies (id, titles) and keywords (id,
> keywords)):
> movies:
> 1|title1
> 2|title2
> keywords:
> 1|keyword1
> 1|keyword2
> 1|keyword3
> 2|keyword1
> 2|keyword2
>
> How do I prevent inserting the same keyword for the same movie?


Make a primary key out of the combo of keyword_id and keyword_name.
Add a constraint to the table to throw and error.

Oh, be sure to read up on a normalization tutorial as well as the docs
on sqlite.org. My advice here is hardly a substitute for either of
those.

Good luck.


-- 
Puneet Kishor http://www.punkish.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
Sent from: Madison WI United States.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to