Confused about Primary Keys, and Foreign Keys

database-designdatabase-recommendation

Im brand new to database design and, I'm slightly confused about Primary Keys, and Foreign Keys and my database design.

Context:
I'm working on a database of museums and Categories will be one way the user will be able to search. e.g click on "Music" and a list of music related museums turn up. Pretty simple.

Problem:
I'm stuck and confused on the Normalisation process of the tables and IF I've got my keys in the right order.

This is what I've got…

enter image description here

I'm not sure, is this overly complicated? OR would it be easier, to add the contents of the "Location" and "Admission" table into the "Details" table and just relate the "Details" to "Categories" table. So, from my understanding going from 1-to-many (at present?) to then becoming 1-to-1???

I apologise if this makes no sense, I am new, obviously VERY confused. It's tricky teaching yourself!

Thanks everyone, I'm really grateful. If you need to see a larger image, it's here…

www.graphicsdesigned.co.uk/Museumscema3.jpg

Cheers!

Best Answer

Teaching yourself database design is indeed very tricky. You might benefit from finding a good tutorial that would help you master the basics. If you want suggestions concerning a good learning vehicle, ask.

Here is a very oversimplified summary of some of the basics.

Before you can design a database, you have to analyze the subject matter in some detail. To quote GregH, "completely understanding how the business works". One way to do this is to get some reliable source on Museums and how they work in the real world, or whatever approximation to the real world you are willing to settle for. You may rely on your own memory for this, but it's better to get some input from experts on Museums, your subject matter. ER modeling can help summarize what you learn.

Another thing you need to spend a little time on is how you intend to use the data. Your design can be influenced by your intended use. This can turn out to be a moving target. You may decide to use the data in more than one way, somewhere in the future. Think ahead as best you can.

Then, you are ready to design your tables. Normalisation is one fairly mechanical approach to avoiding certain pitfalls that can creep up on you if you just design at random. You table design should reflect the relational model of data. The relational model is slightly different from the ER model, in that foreign keys are used to link tables together. But the question of which table non key data should go in is nearly impossible to get right unless you have a clear understanding of the subject matter.

good luck.