Re: Database relations concepts

2010-02-19 Thread Timothy Kinney
No worries, I really appreciate you taking the time to explain the reason for it. I am looking at the CommaSeparatedIntegerField (CSIF) seriously for the exits. It seems straightforward to just use the province_id from the exit provinces as the values in the CSIF, and then it's easy to pull the nam

Re: Database relations concepts

2010-02-19 Thread Javier Guerra
On Fri, Feb 19, 2010 at 2:48 AM, Timothy Kinney wrote: > What does it mean to check about index selectivity? Sorry, my knowledge of > databases is mostly as a user. But I am learning a lot this week. I intentionally left it out, since i'm not the best teacher, you might not need it (if you choose

Re: Database relations concepts

2010-02-19 Thread Le Quoc Viet
Thanks for reasoning :) Regards, Viet. David De La Harpe Golden wrote: On 19/02/10 08:32, Le Quoc Viet wrote: Hi Tim, Thanks for reply. I mean if I want Samurai to be out of all rooms? ForeignKey disallows Null. minor point - ForeignKey(null=True, blank=True) will merrily allow null if you

Re: Database relations concepts

2010-02-19 Thread David De La Harpe Golden
On 19/02/10 08:32, Le Quoc Viet wrote: Hi Tim, Thanks for reply. I mean if I want Samurai to be out of all rooms? ForeignKey disallows Null. minor point - ForeignKey(null=True, blank=True) will merrily allow null if your database allows nullable foreign keys at all (chances are it does). It

Re: Database relations concepts

2010-02-19 Thread Timothy Kinney
It doesn't make sense for the Samurai to be out of all rooms. If it's because he is dead you should create a room for that, such as "Graveyard" or something. However, I think it would work to include "blank = True" in the declaration. This would allow the field to have a null value. -Tim On Fri,

Re: Database relations concepts

2010-02-19 Thread Le Quoc Viet
Hi Tim, Thanks for reply. I mean if I want Samurai to be out of all rooms? ForeignKey disallows Null. Should I do like this: Create a default dummy Room and assign it by default? Viet. Timothy Kinney wrote: I don't understand your question. The Samurai requires one room by the declaration:

Re: Database relations concepts

2010-02-19 Thread Colin Bean
On Thu, Feb 18, 2010 at 11:31 PM, Timothy Kinney wrote: > This is a fabulous response, Peter. Thank you very much for making this so > clear. The samurai_set is a revelation for me as well. I see now that I > should look more carefully at the methods available for the models. > > If I can ask anot

Re: Database relations concepts

2010-02-19 Thread Timothy Kinney
I don't understand your question. The Samurai requires one room by the declaration: class Samurai(models.Model): ... room = models.ForeignKey("Room") ... Since it is a ForeignKey, it can only accept one value and the value cannot be None. Therefore, all samurai will always be in only one room at

Re: Database relations concepts

2010-02-19 Thread Le Quoc Viet
Thanks for explanation. What if Samurai can be outside all Rooms and can be at most at 1 Room at a time? Regards, Viet. Peter Herndon wrote: On Feb 18, 2010, at 11:47 PM, Timothy Kinney wrote: Here's the system I'm currently using that doesn't work too well... Samurai (id, name) Room (

Re: Database relations concepts

2010-02-18 Thread Timothy Kinney
What does it mean to check about index selectivity? Sorry, my knowledge of databases is mostly as a user. But I am learning a lot this week. -Tim On Fri, Feb 19, 2010 at 1:39 AM, Javier Guerra wrote: > On Fri, Feb 19, 2010 at 2:31 AM, Timothy Kinney > wrote: > > is there a way to store a list

Re: Database relations concepts

2010-02-18 Thread Javier Guerra
On Fri, Feb 19, 2010 at 2:31 AM, Timothy Kinney wrote: > is there a way to store a list variable in a model as a field (without > creating another table)? There's no 'list' field type in SQL. There's a 'set' in MySQL; but i think it's not standard, so not supported in Django. but for small sets

Re: Database relations concepts

2010-02-18 Thread Timothy Kinney
This is a fabulous response, Peter. Thank you very much for making this so clear. The samurai_set is a revelation for me as well. I see now that I should look more carefully at the methods available for the models. If I can ask another question about this same topic, is there a way to store a list

Re: Database relations concepts

2010-02-18 Thread Peter Herndon
On Feb 18, 2010, at 11:47 PM, Timothy Kinney wrote: > > Here's the system I'm currently using that doesn't work too well... > > Samurai (id, name) > > Room (id, name, ForeignKey(Samurai), ForeignKey(Province)) > > Province (id, name) > > > Can someone suggest which relationships to use to g

Database relations concepts

2010-02-18 Thread Timothy Kinney
I'm having some trouble wrapping my head around some ORM concepts in Django. I have a Samurai model, and I want to develop a Province and Room model. The idea is that each Room is associated with a Province (is in the province) and each Room can hold multiple samurai (and items). I want to be abl