ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I just have a basic SQL problem that i can't seem to solve.
For my company i am trying to create a database that keeps track of users the computer they are useing and the monitor of that computer.
that's been done and is o.k but here is the problem the relationship between the computer table and the monitor table is a 1-N relationship one computer can be assosiated with many monitors the foreign key or rather the link between the two table is the monitor.
i need to be able to add multiple monitors of the same type e.g we buy viewsonic so in theory if i query the monitors table all the monitor type would come back "viewsonic"
in my current setup once i add one monitor of type "viewsonic" to the computer table i cannot add for the second type the same name. how can i make it so i can add multiples of the same type?
You need to add third table (ok, that's one of the option, but it first the situation good). Rename current 'monitor' to 'monitor model'. The new one will be called 'monitor' and has a rather simple structure: key (primary, unique), monitor serial (or any other id that identifies *one* monitor) and foreign key - monitor type.
So, computer table will have 'monitor id' foreign key - key from new 'monitor table'.
i want to keep try for administrative purposes to keep track of the users in our office, their passwords, email address and computer they are using. realitive to the computer they are using i want to keep track of specifics like cpu, ram, motherboard, serail_number, monitor used. i know i need another table to hold similar infomation for the monitors.
monitor model
monitor_type(fk)
manufacturer
purchase_date
is this correct? are you sure about the associations?
In this case it should be different... 'monitor' beeing instance, where 'model' beeing just a model. Purchase date moved to 'monitor' (it's instance-specific).
table: Computer
cpu
monitor_id(fk)
monitor
monitor_id(pk)
serial_number
monitor_type(fk)
purchase_date
Note: serial number may be id, but SNs are not always ints and don't have a 'standard' form, so integer id, separate from SN may be a good idea.
monitor model
monitor_type(pk)
manufacturer
color, parameters etc
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.