Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Writing Sql statements.

Author  Topic 

Bhujang
Starting Member

1 Post

Posted - 2012-02-26 : 22:37:04
I have just started learning SQL.Today I came across a question, I was having some diifficulty in understanding it.If someone can help me, I will be very thankfull.

There are 2 tables in Database
Employee (Emp_No, Name, skill, Pay_Rate)
Duty Allocation (Posting_No, Emp_No, day, shifts)

I have to find-
(i) Retrieve the shift details for employee named “Mark”.
(ii) Get a count of different employees on each shift.

I cant understand-
(1) What a posting number is.
(2)There may be more than one Employee named Mark, so will the shift datails query give dtails of all people named Mark?
(3)If an Employee has more than one Skill, How I will write it?
(4) Are both tables Normalized or not?

If someone can guide me, it will be very nice of him.

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-02-27 : 04:42:24
Hi,

If this is part of a course then you should probably ask a tutor. However,

1) Posting number is probably the column [Posting_No] on the [Duty Allocation] table. However what it represents I have no idea.

2) If there is more than one entry in the table with a Name of 'Mark' then any query

SELECT * FROM Employee WHERE [Name] = 'Mark'
would get all rows where [name] = 'Mark'

3) Depends on the schema (which will lead into (4)).
Normally (pun intended) you would have another table called [EmployeeSkills] with an foreign key to the {employee] table and then a 1 - N relationship of skills.
However, maybe there is a comma seperated skill list in that [Skill] column (urgh!)

4) Gah. almost certainly not (unless every field is covered by a unique constraint).
Maybe start reading here http://en.wikipedia.org/wiki/Database_normalization

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -