I'm learning SQL and I found a nice exercise (without an answer) so I don't have any hints on whether I am right or not and that's why I'm here.
Design a Computer store database using an ER diagram:
The store sells printers & computers
Some of the computers are laptops
Each printer model has one manufacturer
Each computer model may have more than one manufacturer
Some manufacturers make both printers & computers
Some of the printers print color, some black and white
Each computer must have information on: Processor speed, RAM, HDD space.
The computers that have CD drivers must have information on the CD driver's speed
All the laptops should have information on their screen size
Computers of the same model may differ in hardware (and price accordingly)
First, I tried to make an ER diagram but in the middle of the process I got confused.
For example, Some of the computers are laptops:
Should I add a field (attribute) to the Computer
object which is kind of a boolean field which determines whether the computer is a laptop or not? I don't get it.
Because later on, there is a need to
All the laptops should have information on their screen size
but in this case, which means I need to add a Laptop
object as well, how can I connect between both the objects and claim that one might be the other object.. I don't get it.
Some of the printers print color, some black and white:
how can I do it in the diagram and later on in the database?
Another "kind of boolean" field is the Some manufacturers make both printers & computers. Again, as in my first question, a manufacturer can be for both printers and computers and maybe not. Should I make an entire different object like I did in the diagram below, for each manufacturer? How can I know later on in the database, if a manufacturer is for both printers and computers?
When i'm done, the next step is to write a SQL script to build this whole computer store database.
This is what I accomplished so far: