Relationships

And would each computer (or drive) have it's own table or - everything goes into one (huge) table?

One big table. A good rule of thumb is that tables (and fields for that matter) should be named so generically that someone without knowledge of the system knows what each table/field is for. Also, you shouldn't use suffixes, prefixes or numbers in names. So that means you would never have a table/field named after a specific computer or drive, or have tables/fields like [Computer_1], [Computer_2]...etc. Generic names should rule the day.

Jine don't I want to Join tables? Isn.t that what makes a relatioanal db?

Yes, but in the right manner. Almost all JOINs should be on numeric fields--the autonumber primary ID of one table (parent) goes into the other table (child) and that is how they are joined, not by text like you had done.

If just SELECT * FROM Drives WHERE [Drive Letter]="C:"; doesn't that restrict it to one Drive/Computer with no need for a Computers table?

Technically no, it only restricts it to one Drive (C:) it doesn't restrict it by computer because you have no Computer criteria in that WHERE clause. And this also gets back to you incorrectly storing the ComputerName in the Drive table.

Now here's where it gets tricky and goes back to the storing the ID instead of the ComputerName in Drives. If you do not have a Computers table, then you just store the ComputerName in Drives. If you want a Computers table then you remove ComputerName from drives and store just the ID from the Computers table and JOIN them when you need the Computer Name from Computers and all the Drive information. But like I said, I don't see a need for a Computers table because you only have 1 field of data in it. But also again, you are building this piecemeal so maybe in a few hours you will relaize you need more information in the Computers table and that will necessitate one.
 
@plog, but if there is no Computers table that will mean repetitively saving computer names in Drives table. Names can get lengthy. Even if there is only the one attribute field (computer name) in Computers table, it is still useful as parent or lookup table. Certainly makes building a combobox simple and reduces data entry errors.
 
Combo boxes can be built without a separate table, you can look at existing distinct values in the field to choose from.
 
Yes, that is possible (something I have done). However, still not sure it is best approach for OP to repetitively save computer names in Drives.
 
Good practice (IMO) is to name the ID with the entity eg DriveID, ComputerID.

With only two tables, it may be obvious as to which is which ID but in a database of many tables it helps.

Appologies if I missed somebody already making that point.
 

Users who are viewing this thread

Back
Top Bottom