DataBase autonumbering or custom numbering
<p>My PHP app manages 'events'. I have a class defining all the needed event attributes as private var members. Each var member performs validation via a setter, so every value in the event is valid. Finally I have a factory method using those setters to create new instances of the event. The method performs additional validation, making sure that every required attributed is present when creating a new instance of the class.</p>

<p>And here comes my question.</p>

<p>Every event must have an id. This id is created by the data base when the event is inserted, so in the moment where the event is created but not still inserted there is no id. Since I have all the validation in the factory method I don't want to duplicate that code in other methods just to create a provisional event to insert in the database.</p>

<p>Which is the standar/logical/etc why of doing things?</p>

<ul>
<li><p>Manage my own event numbers, so I can have one before I insert the event in the data base?
Why to made a numbering system for events when the data base can do it for me so good?</p></li>
<li><p>Have a different factory method for a event not still inserted in the data base, which allows a id-less event?
Why to complicate the program logic, having an attribute as required/notRequired depending on its state in the database?</p></li>
</ul>

<p>NOTE: Excuse, I was not able to select an appropiate tag for this question.</p>
