Reputation
7,245
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
1 9 23
Newest
 Explainer
Impact
~170k people reached

Aug
30
answered How do I deal with items that I need to repeat monthly?
Aug
30
answered When to stop splitting tables?
Aug
30
revised Is database normalization dead?
Grammar!
Aug
30
revised Removing “duplicates” within a time range
Added the solution for in and out
Aug
29
comment Removing “duplicates” within a time range
@RLF - Agreed, there are a lot of other possible complications, but OP's question didn't specify any of those. Including lanes is necessary if there is more than one camera reading plates. Similarly, if you want to avoid missing "in and out" situations, you might have to capture when cars leave or make an assumption, as you suggest, about how long a gap should force the presumption of a new visit.
Aug
29
revised Removing “duplicates” within a time range
Another SQL Fiddle tweak
Aug
29
answered Removing “duplicates” within a time range
Aug
28
awarded  Yearling
Aug
17
answered Whether or not to create separate tables
Aug
12
comment Handling or preventing conflicts in a multi-user system
+1 for optimistic concurrency. Note that if you happen to be using SQL Server, there is a native data type called rowversion which automatically assigns a new value each time the record is written to. This same data type was previously known as timestamp, but that syntax is deprecated.
Aug
9
revised How to link a customer to a country when the city/state isn't known
Clarified language.
Aug
9
revised how to explain indexes
Clarified the "problem" being explained.
Aug
9
answered how to explain indexes
Aug
9
answered How to link a customer to a country when the city/state isn't known
Aug
1
answered What is a standard or conventional name for a column representing display order?
Jul
4
answered UNF to 3NF is this relation workable?
Jul
1
comment Data modelling: RBAC for small enterprise software
Mike81 - Changing the primary key of employments to the combination of users_id and organizations_id doesn't change the relationships in any way. The employments table is still a many-to-many intersection table, so each user can belong to many organizations and the role assignments for employees are still organization-specific. It would mean propagating user and organization columns to your role_assignments table, which would allow direct joins for convenience. Your FK constraint would from role_assignments would still be to employments though.
Jul
1
comment What's a good way to model user authorization to hierarchical data?
Joe Celko describes the visitation number approach to managing hierarchical data as nested sets in his book SQL for Smarties which is an excellent resource.
Jul
1
comment Data modelling: RBAC for small enterprise software
You don't state your exact requirements, so it is difficult to critique your model. This model will work fine if all you need is to handle one or more role assignments per user where these roles can be in one or more organizations. It is flexible insofar as it permits different role assignments for each organization. Some people would question the need for employments.id since this table is a pure intersection and you could just as easily use a compound primary key for employments. Some might point out that this could have performance benefits when checking user roles.
Jun
29
answered Implementing a Record Keeper/Rollback System for a MySQL Database