|
For the record, are we talking about MySQL or SQL Server? The syntax in the first post looks like MS, and the first reply is definitely not MS convention.
Anyway, you got the answer, but here's a tip:
It isn't strictly necessary to have a primary key in a table. But there are very, VERY few situations where it really makes sense not to. If a table is going to be used as a log and only ever queried for sums and averages, and you know you're only feeding unique data, you don't need a PK. But if you ever need to update, delete, or select a single row, you need a way to identify that row out of all of what's in your table.
For your person table, you could make firstName + lastName the primary key. I think Tripy recommended an int because they're much faster to compare, and more efficient to index. When you need a foreign key in other tables, an int value makes a great deal more sense than two string values.
But you may want to add a unique constraint to the table to make sure that Forrest Croce isn't allowed two entries. You may not; there actually is another guy who shares my name. It probably depends on the scope of your application. But that's something to consider.
|