mysql - Best practices Boolean vs Integer in SQL -


I want to ask questions about the scenario of this matter. It is believed that I have 3 tables.

  & gt; Class events (models.Model): & gt; Square Meta: & gt; Verbose_name = _ ('Event') & gt; Verbose_name_plural = _ ('Event') & gt; & Gt; Def __str __ (self): & gt; Back self Name & gt; & Gt; Name = models.CharField (max_length = 255, faucet = true)> Description = Model Textfield (tap = true)> & Gt; Organizer = Model.carfield (max_length = 255, tap = true) & gt; Date_from = models.DateTimeField (tap = true)> Date_to = models.DateTimeField (tap = true)> & Gt; Address = model.agarini ('location.Address', null = true, blank = true, related_name = "event_address") & gt; Active = Model Boolean field (default = false)  

  & gt; Class City Nomad (models.Model): & gt; Square Meta: & gt; Verbose_name = _ ('City Name') & gt; Verbose_name_plural = _ ('City Nomads') & gt; & Gt; UID = Model. ItemGold () & gt; Event = model Forward ('event.Event', null = true, blank = true, related_name = 'citynomad_event')  

  & gt; Class Your Singapore (models.Model): & gt; Square Meta: & gt; Verbose_name = _ ('Your Singapore') & gt; Verbose_name_plural = _ ('Your Singapore') & gt; & Gt; Event = model.original ('event.Event', tap = true, empty = true, related_name = 'city_om_a_value') & gt; Ys_priority = models.IntegerField ()  

Then I have the visuals using the Django Framework that will either get the event, only the TravelView event, and then the CitizenMaid only event.

So I am thinking in three ways:

Insert two columns on the 1 Event Model.

is_travelrave = model. BooleanField ()

HelloMonamad = Model. Boolean field ()

2. Insert a single integer

event_identifier = model.IntergerField () (1 as travelwell, identify 2 as the name of the city)

3 Create a table with name Event_identifier (ID and Event_identifier_name)

event_identifier = Model. Forging ('Event_identifier')

Will the bulkian column affect many performance? Is any foreign key unnecessary?

You do not need to do anything manually.

If you want to get all the City Nomad events, you may like them:

  Event.objects.filter (citynomad_event__isnull = False)  

But you have to pay attention to the related_names property in your Singapore -model in this CityNomad related_name -property.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -