473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to represent a timetable in a database?

Hi,

I want to represent a timetable on a mysql database.
I had the idea that i should have three tables:
1.a classdetails table- containing class capacity, classroom name e.t.c
2.a class_sessions table with: start_time and end_time of session,
3.a class_unit table with: the name of the course (MAT003. et.c)

there would also be appropriate foreign keys in class_sessions table and class_unit tables

eventually i want to be able to query for a 'free' class ( one that does not have a class presently-at the time of running of the query)

and return its name e.g ( Room 5b)

Will the tables i have listed be sufficient for the query at hand?

any ideas how to make this better will be appreciated.

Thank you.
Jan 26 '11 #1
2 9668
Jerry Winston
145 Expert 100+
I don't know if this is an improvement but here's a different way to look at class organization:

CourseTable: name of class, course code, Description("Math for DB's", MATH, "Database math")

CourseSectionTable: course section information (like your details table) meeting times, locations instructors ect.

There's alot of detail associated with large course management systems(like at colleges and universities) that we haven't began to touch. It would help to know how much detail you're looking for and how you want to use the database.

(It just so happens I work at a university)
Feb 2 '11 #2
Thanks,
I have left out a lot of detail because of how i intend to use the database. Good thing you work at a university so this may sound piece of cake ish.
Heres is the problem for which i intend to use the database:

In my institution there are several computer labs. These labs have classes e.g in lab1 there is C# programming, lab2 introduction to Unix e.t.c,

When there are no classes in these labs, students can use these 'free' labs for homework, research, twitter e.t.c.

I want to make a simple SMS application using php that returns the name of the 'free' lab when a user sends the keyword 'free' to a certain number.

I am stuck at the logic of representing the timetable in a mysql database.

Just to give you an overview of the detail I have in my database:

Expand|Select|Wrap|Line Numbers
  1. -- phpMyAdmin SQL Dump
  2. -- version 3.3.2deb1
  3. -- http://www.phpmyadmin.net
  4. --
  5. -- Host: localhost
  6. -- Generation Time: Jan 24, 2011 at 04:51 PM
  7. -- Server version: 5.1.41
  8. -- PHP Version: 5.3.2-1ubuntu4.5
  9.  
  10. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  11.  
  12.  
  13. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  14. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  15. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  16. /*!40101 SET NAMES utf8 */;
  17.  
  18. --
  19. -- Database: `CompLabTimetable`
  20. --
  21.  
  22. -- --------------------------------------------------------
  23.  
  24. --
  25. -- Table structure for table `labdetails`
  26. --
  27.  
  28. CREATE TABLE IF NOT EXISTS `labdetails` (
  29.   `LabId` int(15) unsigned NOT NULL AUTO_INCREMENT,
  30.   `LabName` varchar(20) NOT NULL,
  31.   `LabOpeningTime` time DEFAULT NULL,
  32.   `LabClosingTime` time DEFAULT NULL,
  33.   PRIMARY KEY (`LabId`)
  34. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
  35.  
  36. --
  37. -- Dumping data for table `labdetails`
  38. --
  39.  
  40. INSERT INTO `labdetails` (`LabId`, `LabName`, `LabOpeningTime`, `LabClosingTime`) VALUES
  41. (1, 'Menengai', '08:00:00', '20:00:00'),
  42. (2, 'Kiambere', '08:00:00', '20:00:00'),
  43. (3, 'Suswa', '08:00:00', '20:00:00'),
  44. (4, 'Elgon', '08:00:00', '20:00:00'),
  45. (5, 'Aberdare', '08:00:00', '20:00:00'),
  46. (6, 'Longonot', '08:00:00', '20:00:00');
  47.  
  48. -- --------------------------------------------------------
  49.  
  50. --
  51. -- Table structure for table `labunit`
  52. --
  53.  
  54. CREATE TABLE IF NOT EXISTS `labunit` (
  55.   `UnitId` int(11) NOT NULL AUTO_INCREMENT,
  56.   `UnitName` varchar(45) DEFAULT 'LabLecture',
  57.   `UnitFaculty` varchar(45) DEFAULT 'UnNamed Lecture Faculty',
  58.   `IdSessionTime` int(15) unsigned DEFAULT NULL,
  59.   PRIMARY KEY (`UnitId`),
  60.   UNIQUE KEY `IdSessionTime_UNIQUE` (`IdSessionTime`),
  61.   KEY `IdSessionTime` (`IdSessionTime`)
  62. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COMMENT='The Class Table contains information about the session to be' AUTO_INCREMENT=4 ;
  63.  
  64. --
  65. -- Dumping data for table `labunit`
  66. --
  67.  
  68. INSERT INTO `labunit` (`UnitId`, `UnitName`, `UnitFaculty`, `IdSessionTime`) VALUES
  69. (1, 'Advanced Networking', 'FIT', NULL),
  70. (2, 'Sage', 'Fcom', NULL),
  71. (3, 'Pastel', 'SOA', NULL);
  72.  
  73. -- --------------------------------------------------------
  74.  
  75. --
  76. -- Table structure for table `lab_sessiontime`
  77. --
  78.  
  79. CREATE TABLE IF NOT EXISTS `lab_sessiontime` (
  80.   `IdSessionTime` int(15) unsigned NOT NULL AUTO_INCREMENT,
  81.   `Start_time` time NOT NULL,
  82.   `End_time` time NOT NULL,
  83.   `Day_Of_Week` varchar(45) NOT NULL,
  84.   `LabID` int(15) unsigned NOT NULL,
  85.   PRIMARY KEY (`IdSessionTime`,`Start_time`,`End_time`,`Day_Of_Week`),
  86.   KEY `Lab_ID` (`LabID`)
  87. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
  88.  
  89. --
  90. -- Dumping data for table `lab_sessiontime`
  91. --
  92.  
  93. INSERT INTO `lab_sessiontime` (`IdSessionTime`, `Start_time`, `End_time`, `Day_Of_Week`, `LabID`) VALUES
  94. (5, '14:30:00', '15:00:00', 'Saturday', 1),
  95. (3, '11:15:00', '12:15:00', 'Tuesday', 3),
  96. (1, '08:15:00', '10:15:00', 'Monday', 5),
  97. (2, '11:15:00', '01:15:00', 'Monday', 5);
  98.  
  99. --
  100. -- Constraints for dumped tables
  101. --
  102.  
  103. --
  104. -- Constraints for table `labunit`
  105. --
  106. ALTER TABLE `labunit`
  107.   ADD CONSTRAINT `IdSessionTime` FOREIGN KEY (`IdSessionTime`) REFERENCES `lab_sessiontime` (`IdSessionTime`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  108.  
  109. --
  110. -- Constraints for table `lab_sessiontime`
  111. --
  112. ALTER TABLE `lab_sessiontime`
  113.   ADD CONSTRAINT `Lab_ID` FOREIGN KEY (`LabID`) REFERENCES `labdetails` (`LabId`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  114.  
  115.  
Feb 4 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chris Rodgerson | last post by:
Hi all, I have a page with the date being passed in(calendar_week.php?date=6-4-2005), but what i want to do is display a timetable for the week that date falls on, from 8am-8pm in half-hour...
0
by: richard | last post by:
The Open Source Developers' Conference is on next week (Dec 1 - 3) in Melbourne (Australia) and the conference timetable is now available: <http://www.osdc.com.au/news/timetable.html> As you can...
1
by: Luciano Vittoretti | last post by:
Hi everyone, I need some PHP script to make a documentation of database (like phpdocumentator, www.phpdoc.org ), moreover I need that document act like a database administrator, in other words,...
6
by: MA | last post by:
Hi all! Im going to develop a timetable with c# and asp.net. Does anyone knows of any good site where i can find information? I have googled for a while, but cant find anything. /Marre
2
by: steve | last post by:
Hi All I need to learn how to update a SQl server or Access database located on a web server from my windows forms application, via the internet I have a customer who wants to run several...
0
by: Paul Boddie | last post by:
EuroPython is the European Python and Zope Conference, taking place this year in Vilnius, Lithuania from Monday 9th July to Wednesday 11th July. The last day of EuroPython's early registration...
17
by: chaos | last post by:
HELLO !!! i doing timetable system using php. i now stuck in part whereby showing the change between Original TimeTable and Proposed TimeTable in chart so that the user will know the change he...
26
by: hiyamwah | last post by:
Hi,This is my problem which my work want me to solve: This system is intended to provide the school timetabler with information to support his/her timetabling activities. Please note it is not...
0
by: smoothkriminal1 | last post by:
the question is u read timetable of 40 students from file n den find da slot where all fourty students dnt hve clash...if any.... may b i ll be able to make clash logic but i m even just nt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.