Originally posted by pecondon
2. If you must (you maybe want to keep your job), use string. Ints are for data that obey the rules of arithmetic. Two of these things will never be added, or multiplied together, but they will be compared for
equality, which can be done for strings.
Hold on a second.
If you're going to talk theory, talk theory. This "numerical id" is *not* a random string. It can't be "pecondon", for example.
Speaking in terms of theory, we'd want a domain called "buidling id" that contained only the values that were valid building ids.
Theoretically, this is a problem *completely* orthogonal to the relational model. It's about expressing a scalar value, not tables and joins.
Since SQL doesn't have proper domain support, the best you can do is define a view that will enforce integirty. I'm not saying the example I gave is necessarily the best way, *but* because it uses declarative rules I think it would be simpler than something, say, based on triggers.
The idea that "ints are for data that can be used arithmetically" is very poorly expressed. Integers are just values, like any other. How they're going to be used is immaterial when expressing the relation variable's predicate.
first normal form is actually about repeating groups
1NF simply states that the relation has a valid predicate. *All* relations are in 1NF by definition. (Not all SQL tables are relations.)