title: Database Newb - Primary key, Foregin Key, No key at all?
body: <p>I am a sophomore computer science student at a university. I'm making a online app with php/mySQL. This is my first experience with both PHP and mySQL. Anyway I am making an app that keeps track of baseball games. The user creates a team of players and starts a game against another team, the user enters in outcomes while the app scores the game and keeps player stats. I am designing the database and was hoping someone could clarify for me:</p>
  
  <p><strong>Primary Key-</strong>
  I am pretty sure I understand what this is. Basically its the unique identifier of each row, used for distinguishing each row.</p>
  
  <p><strong>Foreign Key- </strong>
  Right now I have a "Players" table, I also have a "PlayerStats" table. If I understand it correctly (which I probably don't) the "Players" table has a column "playerStatsId" which is the primary key of the "PlayerStats" table. This works because there would only be one stats table per player.</p>
  
  <p><strong>No key???- </strong>Ok so heres my example. Each user of my app should have the ability to add as many teams as they want to the database. They can only edit the games of a team that they "own". I was thinking I could accomplish this by having a table with two columns: "username" and "teamId". Then I could search through the table and pick out the teams that belong to a certain user. I don't feel like this is the answer because it doesn't seem very efficient. Is there a better way?</p>
  
  <p>I am grateful for any help! Thank you!!</p>