I have 7 tables one is faculty_subjects rest are Monday,Tuesday,Wednesday,Thursday,Friday and Saturday my tables structure is like this
i have attached image url
http://s27.postimg.org/434y3255f/School_Management_System.jpg
i tried to make whole design here but everything mashedup
live static page http://www.school.eptins.com/
when someone select class and section relevent to that subjects and faculty display in fields.
I think time-table for one class is a table in itself. Instead of scattering time-table information of a classroom over 6 different tables, you could keep a table name timetable_IA and that table could have first column for periods (Period I, Period II, Period II, ...) and second column for subjects on Monday, third column for subjects on Tuesday, etc.
That way, when a person chooses class IA, you have to just gather information from one table only.
For the second table (Subject Faculty), you could make an array of subjects appearing in time-table by reading time-table of IA, and then call in names of faculty teaching those subjects and construct the table.
I'm coding a Classified Ads web application. The application has several types of Ads:
General ads(electronics, toys, pets, books...)
Real estate (houses, apartments, terrains...)
Vehicles (motocycles, cars, vans, trucks...)
Each type has several common fields (id, title, description) and also some that are exclusive to its kind:
General Ads (no exclusive fields)
Real estate (area, type-of-property...)
Vehicles (type-of-vehicle, cubic-capacity, kilometers...)
What is the most recommended approach to this situation?
A table that contains all fields and leave empty the fields that
don't apply to the current recordset.
A main table with the fields common to all Ads, and an additional table for each type of Ad that has exclusive fields.
One table for each type of Ad.
Other
I would build a solution depending on various criteria :
If you believe the table will be large in the future (a lot of ads to be published), you may want to minimize the number of JOINs for better performance => option 1. "one table with empty fields when not relevant to ad type"
Previous comment applies especially if your data storage cost is low.
If you have to query the data against certain field values (e.g. house size, car kilometers), you might avoid the solution described by phpalix (ad_type | property | value) or Andy Gee since your SQL syntax will be a nightmare, and prefer to have all your data in the same table (again).
If there are A LOT of custom fields per ad type, you might prefer to separate each ad type in their own table, for easier maintenance and data storage optimization. Then you can either JOIN or UNION to query your ads lists.
I'll add to my answer if i think of something else.
You can normalise (a table for the abstract concept and a table the the specialised one) or denormalise (a table with all the fields)
As always, the choice must be done according to the cost of each solution, reprensented by the speed of the queries (normalised model means more joins (buffer/cpu) whereas denormalised more disk reads usually because the columns are sometimes retrieved when it is not necessary) or the storage required in both cases.
All solutions are acceptable and a matter of preference, performance, complexity and design needs. The terms for what you are discussing are Table-Per-Type, Table-Per-Class and Table-Per-Hierarchy. If you google on these you are guaranteed to get a ton of Entity Framework results, but the underlying design considerations are much the same.
For flexibility I would have all the field in a separate table then allow the assigning of each field to each ad type. This would also allow you to add and remove fields easily at a later date.
Each field may have different types of data so this information should also be in a separate table.
Something like this (not very clear sorry)
Table: fields
field_id, field_type, field_name
1 1 title
2 1 price
3 2 size
4 3 description
5 1 square meters
Table: field_types
field_type_id, type
1, textbox
2, select_box
3, text_area
Table: field_data
field_data_id, ad_id, field_id, field_type_id, field_data
1 1 1 1 Cool t-shirt
2 1 2 1 5.99
3 1 3 2 L,XL,XXL,XXXL
4 1 4 3 Some description
5 2 1 1 Nice house
6 2 2 1 250000
7 2 4 3 Some description
8 2 5 1 1024sq/m
Table: ad_types
ad_type_id, ad_type_name, fields
1 general 1,2,3,4
2 real_estate 1,2,4,5
Well, store the values in columns and not in rows, so create a table and have 3 columns:
ad_type, property, value
define your properties for each type of ad and query the ad type for its fields.
Hope that helps
I'm designing a database for a school management system and am facing couple of problems and I thought of throwing it here and someone might help.
I've a STUDENTS table that holds students details and CLASS table that holds class information. In the application one will need to know to which class a student should be promoted if he or she passes the exam. So the class table looks like this in my design:
+----------------------+
|id | name | parent_id |
+----------------------+
where the parent_id is the id of the previous class. Now each class has more than one stream (e.g., class form 1 can have 3 streams: form 1A, form 1B, form 2B etc) and each stream has students say form 1A has 40 students and so forth. So i have a stream table with this design:
+---------------------------------------------+
| id | student_id | class_id | stream_name |
+---------------------------------------------+
so for each stream with 40 students I will have 40 rows in the stream table and the stream name will contain the name like A, B, C or whatever the user wants it to be named. Is this the best design regarding my problem? Will this design affect performance of the system in any way? What is the best database design approach with the problem in question?
STUDENTS table carries information about the student like their name and parents information.
EDIT: The stream table is updated every-time a students is registered or when the new academic year has been registered for-instance if i were in stream A of form 1 then all the student in that class (form 1) should be promoted to class form 1 retaining their stream so if i was in form 1A then the next academic year i will be in form 2A. There is an ACADEMIC_YEAR table that holds the information of academic year such as when does it start and end and all sort of information, also there is a EXAM_RESULTS table which stores results for each student in particular stream in an academic year. For records i will need to know all stream and classes that the student has studied.
Thanks in advance
Your approach is on the right track. I would like to recommend the following:
a) Add a start date and end date to the stream table so that you can calculate which period the student was in the stream (will be able to handle students who start mid way the year or who leave before the year ends). This can also handle students who repeat because they will be in the same class for a new year
b) In the exam results table, add stream_id, class_id, student_id fields so that you can associate the exam with a class, student and stream. There seems to be a duplication to have the stream_id in addition to student_id and class_id but from experience it speeds up queries when you do not have to join to the stream to find out which class and student the exams belong to.
I am trying to create a Hotel reservation system using wordpress. Now, I know all the queries for data retrieval in a non-wordpress mode but I am facing some data-organization issues in dealing with wordpress. My hotels details are stored in the posts table and as custom fields for the hotel. For rates of the hotels, I created a different table according where rates vary according to months. I'd like the data to be displayed like this in my search results page:
Hotel_1 Name: (Will come from Post Name)
Hotel_1 Details: (Will come from custom fields)
Hotel_1 description: (will come from excerpt)
Room_1 Name for Hotel_1: Total Rates for selected dates
Room_2 Name for Hotel_1: Total Rates for selected dates
----------------------------------------------------------
Hotel_2 Name: (Will come from Post Name)
Hotel_2 Details: (Will come from custom fields)
Hotel_2 description: (will come from excerpt)
Room_1 Name for Hotel_2: Total Rates for selected dates
Room_2 Name for Hotel_2: Total Rates for selected dates
----------------------------------------------------------
and so on and so forth.....
----------------------------------------------------------
Pagination>>
----------------------------------------------------------
My rates table looks like this
mysql> select * from rates;
+-------------+---------+---------+-------------------+------------+------------
+-----------+--------------+-----------+------------------------------------+
| primary_key | post_id | room_id | room_type | start_date | end_date
| adultRate | extraBedRate | childRate | inclusions |
+-------------+---------+---------+-------------------+------------+------------
+-----------+--------------+-----------+------------------------------------+
where post_id = ID of the post in wp_posts table
room_id = ID given to a room
room_type = Name of the room
1 post (post_id) may have several room_types.
Any help is much appreciated. Thanks.
I just need help on
a. how to organize or create relationships among table to get desired result, &
b. how to get them displayed in wordpress. Some classes or functions need to be considered.
I am very very new to php and mysql and this is my first assignment. My skill level is such that I can make changes to a code but right now it is very difficult for me to write from scratch. However with the help around here I intend to learn.
thanks
You're approaching this problem from the wrong point of view. There's a better way to handle this kind of information on WordPress and it doesn't (necessarily) involve creating new tables. WordPress handles CRUD natively so you will use pre-made functions instead of writing it from scratch.
Also, forget about using the original posts structure to do this, it can be a major headache. Instead, read everything you can about Custom Post Types and specially this awesome tutorial from Justin Tadlock
I am making a website that will show night club revelers events and night establishments in a big city. Events could number in the hundreds.
A user should be able to add certain details when adding their event on the site e.g.(in the events table) event_name, event_description, event_date, event_photo_url etc.
I want users to be able to search or find certain events or establishments based on interests or music genre.
I have an interest table and a genre table in MySQL:
interests table
interest_id interest-name
1 Shoot Pool
2 Karaoke
3 Lounge
4 Live Band
5 Dance
6 Watch Sports
genre table
genre_id genre_name
1 Hip Hop
2 Soul
3 Reggae
4 Pop
5 Bangra
6 Rock
7 House
8 Country
9 Gospel
10 Carribean
11 Bongo
12 Genge
13 Mugithi
14 Dholuo
15 Kamba
16 Classical
17 Childrens
18 Latin
19 Jazz
20 Musicals
21 Middle Eastern
I have 2 other tables to link events with genres and events with interests ie;
event_genre table
event_genre_id
event_id
genre_id
and event_interest table
event_interest_id
event_id
interest_id
An establishment or event can have more than one interest e.g a club where one can play pool and watch the game. The same goes with music genres. A wide variety of music can be played in an establishment or event.
A user whould be able to make multiple selects from genres and interests.
My question is, do I have drop down list menus for each of the interests and genres? Can I have multiple selects for a drop down list menu and/or radio buttons? Is there a better way of implementing what I need?
I would go with a mess of checkboxes. The user would be able to check all of the interests or whatever that they are interested in. To process this you would just build a list of checked values and then pass that list into the query to filter the results. Make sense?
You could do two list boxes. This would allow you to select multiple genres and multiple interests in two simple controls which would save realestate and allow you to easily display and sort the available selections...
then on your server side you would just have to parse the values to build your query... THAT will probably be the hard part.
your value will more likely be returned as an array... not sure how that all works in php, but you would split your items down to an array object and basically loop through them.
you would then add AND genre = arItem(x) to your query and the same with interests.