You have been tasked to create a database that will store a list of all managers and the
employees who report directly to them. The following is stipulated:
• No manage is managing more than three people.
• No employee can work for more than one manage.
Which of these designs represents a normalized schema that meets the project
requirements?
A.
CREATE TABLE ‘manager’
‘manager’ varchar (50) DEFAULT NULL,
‘employee2’ varchar (50) DEFAULT NULL,
‘employee’ varchar (50) DEFAULT NULL,
UNIQUE ( ‘manager ‘, ‘employee1’, ‘employee2, ‘employee3’)
)
B.
CREATE TABLE ‘managers’ (
“id’ int(11) NOT NULL AUTO_INCREMENT,
‘manager’ varchar (50) DEFAULT NULL ,
PRIMARY KEY (‘id’)
)
CREATE TABLE “employees’ (
‘id’ int(11) NOT NULL AUTO _INCREMENT,
‘manager_id’ int(11) DEFAULT NULL,
‘employee varchar (25) DEFAULT NULL,
PRIMARY KEY (‘id’)
)
C.
CREATE TABLE ‘manager’ (
‘manager’ varchar (50) DEFAULT NULL,
‘employee_list’varchar (150) DEFAULT NULL,
)
D.
CREATE TABLE ‘message’ (
‘id’ int(11) NOT NULL AUTO_INCREMENT,
‘manager’ varchar(50) DEFAULT NULL,
PRIMARY KEY (“id’)
)
CREATE TABLE ‘employees’ (
‘id int (11) NOT NULL AUTO _INCREMENT,
‘ employees’ varchar(25) DEFAULT NULL,
)
Looks like A
https://dev.mysql.com/doc/refman/5.6/en/create-index.html
A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row.
A
B
i think it’s B. Because for N:1 relationship (1 to many) you need 2 tables.
If you store them in 1 table you will have a lot of problems.
For example if manager named ‘IdontGiveAfuck’ has 1 employee that means that the rest 2 columns would have value NULL. and that’s not good.
All logics are accepted. how B satisfies the condition?
https://stackoverflow.com/questions/13513168/sql-m1-relationship
https://www.youtube.com/watch?v=KjA2LhT4TRU
No manager is managing more than three people.
But nothing about less than three people.
What if 2342342 managers have only 1 employee?
THAT’S LIKE 2342342 * 2 NULL COLUMNS!!! xD
that’s extra space in the database and index usage is damaged.
so that’s why i don’t think it is A.
anyway, B seem to miss the foreign key so none of the options are correct.
it can’t be A for sure. Because two managers can have the same name.
So column manager can’t have unique index.