CCL (or CCW in some states)
Many more different types of licenses and certifications are going to be added eventually so as you can see these relationships are going to get complex. So If I'm grasping this correctly let me try some code to see if I'm on the right track....
class NRA_Certs(models.Model):
CRSO = models.BooleanField(blank=True, null=True, "Chief Range Safety Officer")
HFS = models.BooleanField(blank=True, null=True, "Home Firearm Safety")
MCR = models.BooleanField(blank=True, null=True, "Metallic Cartridge Reloading")
PPH = models.BooleanField(blank=True, null=True, "Personal Protection in the Home")
PPO = models.BooleanField(blank=True, null=True, "Personal Protection Outside the Home")
PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell Reloading")
SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be a Victim Workshop")
RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a Victim Online")
NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA Muzzleloading Pistol Shooting")
NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA Muzzleloading Rifle Shooting")
NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA Muzzleloading Shotgun Shooting")
class NRA(models.Model):
cert_type = models.ForeignKey(NRA_Certs)
name = models.CharField() # Is this necessary? Can the name be set to text in the boolean fields from NRA_Certs?
expiration = models.DateField(blank=True, null=True)
Does that look right or am I missing it completely. I'm not sure sure on the NRA_Certs all being boolean, my thinking is that whether they have that certification should be as simple as true/false.
Thanks once again for all the help.
On Wed, Jun 27, 2012 at 7:38 AM, j_syk <jesy...@gmail.com> wrote:> One to One is the right type for linking a user to a profile in the Django
certs
person
Does that make sense? If so each table would be represented by a single class and I think I understand then how they relate to each other and I just need to stop worrying about the View.
Thanks for all your patience everyone as well. Like I said, I'm not classically trained in computer science so there are a lot of concepts that elude me and some lingo that I don't get but the concepts I may grasp if I just understand the translation.
On Wed, 27 Jun 2012 08:02:37 -0700, David Wagner <cptn...@gmail.com>
declaimed the following in gmane.comp.python.django.user:
Ugh!...
I'm not familiar enough with Django's internal format so I'm using a
form of old relational theory notation: tablename(_key_, /foreignkey/,
other, fields...)
NRACertificate(_ID_, certificateName, other, type, specific,
attributes))
{I forget your individual model so a generic}
Person(_ID_, name, other, stuff)
Person_NRACertificate(_ID_, /personID/, /nracertificateID/,
dateCertified, dateExpires, other, certificate, specfic, data)
Django can build this intersection table automatically -- but it
would only have _ID_, /personID/, /nracertificateID/! I think, for your
information, you'd want to define your own "through" table to hold the
data specific to an instance of a certificate as held by a person.
Same with concealed carry permits IF you need a list on a, say, per
state basis.
Note though, that if the /lists/ don't carry any significant
information beyond the name of the item, you just need one-to-many
configurations. For example, if the only information you track for CCW
is: who (foreign key to Person), license number, issuing state (or other
government entity), date issued, date expires... then a one-to-many is
all you need. (Though you may find you need another one-to-many --
California's rare CCW includes a list of /which/ firearm(s) are
permitted [if you sell one gun and buy a different one, you have to beg
the government to update the CCW with the new gun's information]).
The NRACertificates table may also not be needed if all it provides
is a list of names to populate a dropdown selection box -- might speed
up processing by just hard-coding the list and saving the name directly
(replace the /nracerticateID/ in the intersect table with the actual
text of the certificate as selected from the dropdown selection.
Bigger note: You will NOT be using a multiple selection list... More
reasonable is an "add new certificate" button which brings up a form
from which to select one certificate (by name in dropdown), and fields
for the dates, and whatever else is common to certificates.
When displaying a person, the certificates would be (if I recall
Django terms) a "formset" (where the "form" is for a single
certificate's data).
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
On Wed, 27 Jun 2012 11:48:22 -0700, David Wagner <cptn...@gmail.com>
declaimed the following in gmane.comp.python.django.user:
> Looking at that I think I may need to add a foreignkey to cert_types
> relating to person since a person can have multiple certification types
> (NRA Instructor, CCL Instructor, etc).
Well, this has just added a different aspect... That of INSTRUCTOR
(my memory of the first messages came across more as a certificate that
one had attended a course <G>, not that it meant they could teach the
course).
In the case of instructors -- what is the difference between "NRA"
and "CCL" instructor? "NRA" specifies an organization that provides the
certification in /something/, but "CCL" is a /something/ but who issues
it?
Okay, looking at these as teaching certificates...
Certificates
ID #primary key
Name #text string for the common name of the class
IssuingAuthority #NRA or government entity
DateFirstAuthorized #not date of issuance, but a double check that
#an issued certificate date does not come
#before the "class" was created
RenewalPeriod #how often the certificate needs to be renewed
Persons
ID
Name
Address
whatever
Issued #or PersonsCertificates if you want to name the sources
ID
pID foreign key (Persons.ID) #who this certificate was issued to
cID foreign key (Certificates.ID) #what type of certificate
DateIssued #constraint DateIssued > DateFirstAuthorized
CertificateNumber #document number
DateExpires #for things that need to be renewed periodically
#= DateIssued + RenewalPeriod
UniqueKey (pID, cID, CertificateNumber)
#including certificate number means you can track renewals
#as a renewal would have a different serial number
This is a many-to-many between Persons and Certificates, in which
the intersection table (Issued) contains additional information.
Looking at that I think I may need to add a foreignkey to cert_types relating to person since a person can have multiple certification types (NRA Instructor, CCL Instructor, etc).
On Wed, Jun 27, 2012 at 11:40 AM, David Wagner <cptn...@gmail.com> wrote:
i think I may just be over thinking this. The last time I did any significant coding for the web as pre-php5 and so this whole MVC thing is something to adapt too for sure.
I think I need to start thinking of the Model in the same way I would design a database back in the day with phpMyAdmin. I think I'm getting bogged down in trying to understand how it will relate to the View. Perhaps I need to just put the View out of my mind for the time being.
So thinking of this as just a database schema it would be something like (in psuedo-code)....
cert_types
- type
- date_created
certs
- type = foreignkey(cert_types)
- name
- state (optional)
- date_created
person
- name
- etc...
- certificates = foreignkey(certs)
--