User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 361,631 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,168 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 578 | Replies: 3
Reply
Join Date: Mar 2008
Posts: 7
Reputation: Neke is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Neke Neke is offline Offline
Newbie Poster

Database design for a school' sports day

  #1  
Mar 27th, 2008
Hello all,
I'm new in this group and with designing databases. I would like to design a databse for managing data about the sports day for a school.

I have been able to create the following tables: Pupil(differnt class and age group), Event(hockey, rugby, swimming,relay race), Staff, Equipment(used for the event).
I don't know if i have the ritght classes for the tables and could you kindly tell me how my ER/EER model would be used to answer some of their needs like drawing up with a list of events and start time, count all events participated by each group.
Thanks.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: homeworkhelp.co.in
Posts: 790
Reputation: ithelp is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 59
ithelp ithelp is offline Offline
Master Poster

Re: Database design for a school' sports day

  #2  
Mar 28th, 2008
Yes you are right track , now identify the relationships among the entities.
Reply With Quote  
Join Date: Mar 2008
Posts: 7
Reputation: Neke is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Neke Neke is offline Offline
Newbie Poster

Re: Database design for a school' sports day

  #3  
Mar 28th, 2008
ok here are my enttities and their attributes
Pupil
P ID PK
Class ID
PfName
PlName
PAge

Class
ClassName
ClassType


Events
EventName PK
EventTime
StaffID

Equipment
Eqipment Name PK

Staff
Staff ID
SfName
SlName


Team
Team number

i'm afraid that from the tables , i may not be able to write query to list all events and start time, all pupils in a given team, and produce a list of winners for all events
Reply With Quote  
Join Date: Mar 2008
Posts: 25
Reputation: blater is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
blater's Avatar
blater blater is offline Offline
Light Poster

Re: Database design for a school' sports day

  #4  
Mar 28th, 2008
You need a table to record the results of each event (If you are only interested in the winner, not second place, third place etc then you could just put a pupilId in the event table to record just the winning pupil).

You need the eventId against the equipment table to associate that item of equipment with a particular event.

You also need a table to record which pupils are in each team.

Good luck with the project, Here's a suggested schema...

/*
** The pupils..
*/
Pupil
PupilID int not null primary key,
ClassID int not null, -- foreign key to Class.classID
PfName varchar(32),
PlName varchar(32),
PAge int

/*
** The classes
*/
Class
classID int not null primary key,
ClassName varchar(32),
ClassType varchar(16)

/*
** The list of events
*/
Events
EventID int not null primary key,
EventName varchar(64),
EventTime datetime,
StaffID int -- foreign key to Staff.StaffID


/*
** The results of each event
** The id and position of each pupil is inserted into this table
** after each event to record the results.
*/
EventResults
EventID int not null -- foreign key to Events.EventID
PupilID int not null -- foreign key to Pupils.pupilID
position int -- the position the pupil came in the event


/*
** The equipment used for an event
** There will be zero to many entries in here for each event.
*/
Equipment
EventID int not null, -- foreign key to Event.EventID
EquipmentName varchar(32)

/*
** Master list of staff members
*/
Staff
StaffID int not null primary key,
SfName varchar(32),
SlName varchar(32)

/*
** Master list of teams
*/
Team
TeamID int not null primary key,
teamName varchar(64)

/*
** List of team members for each team
*/
TeamMembers
teamID int not null, -- foreign key to Team.TeamID
pupilID int not null -- foreign key to pupils.PupilID
[/code]


to list all events:
	select * from Events order by eventTime

to list all pupils in a given team:
	select t.team_name, pfName + ' ' + plName as pupil
	from TeamMembers m, 
               Team t, 
               Pupil p
	where t.teamID = m.teamId
	and   p.pupilID = m.pupilID
	and   teamName = 'red team'

to list winners for all events
	select e.eventName, pfName + ' ' + plName as pupil
	from  EventResults r, Events e, Pupils p
	where e.eventID = r.eventID
	and    p.pupilID = r.pupilID
	and    r.position = 1
	order by eventName
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Database Design Marketplace
Thread Tools Display Modes

Other Threads in the Database Design Forum

All times are GMT -4. The time now is 6:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC