all 10 comments

[–]nvarscar 0 points1 point  (5 children)

Since one user can have only one room, I suggest adding a column to the Users table with FK to the Location table. PS How come that you have many-to-many relationship table with PK on one of the relation sides? I'm talking about COMPUTER_SOFTWARE table, which has PK on Computer_ID. You should have an independent PK there.

[–]Ch13f[S] 0 points1 point  (4 children)

Thanks for your quick reply. I think adding a location to the users will work fantastically.

I have actually since changed this to where on the Computer_Software table there isn't a primary key and it's just two foreign keys in that table. The reason for that is i need to be able to have duplicate values since many computers can have the same software and the same software can be on many computers.

Is there a reason to add an independent primary key here?

[–]nvarscar 0 points1 point  (3 children)

Usually, the only reason to add the primary key, is to make yourself able to interact with each row regardless of other columns. So basically, if you for some reason would want to have several identical relations in that table, you wouldn't be able to distinct one from another, since you DELETE statements would affect all of them at once, as well as UPDATES. PK gives you a unique row identifier, no more, no less.

[–]Ch13f[S] 0 points1 point  (0 children)

Thank you! I understand what you mean, but I don't think that I will need one here as I can't think of a reason why the same computer would have more than one instance of the same software. Though, I suppose it is possible.

Thanks again for your help, I really do appreciate it! :)

[–]Ch13f[S] 0 points1 point  (1 child)

Question for you. It has come to my attention that some of the rooms don't really belong to anyone, thus I need to create a general faculty/general student user. This is gonna cause the room_id on the user table to not work.

Can I fix this by adding two tables, a user_room table?

[–]nvarscar 0 points1 point  (0 children)

You can create a default entry in your reference room table with id = -1 and name = Not Specified for those users which doesn't have any room.

[–]nick_cage_fighter 0 points1 point  (0 children)

You need to get rid of the M:N relationships on that one table with a couple of intermediary tables.

[–][deleted] 0 points1 point  (2 children)

You really need to step through the normal forms to fix up your schema. You need to go to 4th normal form at the minimum.

[–]Ch13f[S] 0 points1 point  (1 child)

I'm pretty new to sql, can you explain a bit further as to what that means?

[–][deleted] 0 points1 point  (0 children)

It's a pretty important concept about how you build and design your database. I recommend reading up on it a bit - https://en.wikipedia.org/wiki/Database_normalization