im trying to store University Seat number of students in 100+ colleges
- Format of Seat Number - [college code] [batch year] [department] [seat number]
example - if 'ab' is coleg code, '10' batch, 'cs' or computer science dept and seat number is '001'
then Seat Number will be ab10cs001
- Please ignore the seat number '001' and '10' batch as i will not be storing dat ..
- Have 100+ colleges
- Each coleg may have 4 departments , 5 or even 10-12 departments [if ur using array pls use dept, dept... as i will be using this in a for loop..
- There should be a variable [like flag] which will tell if a particular dept exists in the colleg or not ...
pls suggest keepin in mind CPU rsources, memory ...
im just a beginner in PHP ... so any code wil be helpfull..
Could you provide some more details - do you already have the data in a DB and you want a data structure to use for output? Or are you starting from scratch and designing an app? What kind of operations will be done with the data?
hii bro.. thanks a lot , really appreciate ur interest in solving my prob..
ill tell you about this part briefly..
and i dont have this in the database, the data is in a file but its not in a proper order.. so have to manually insert the college code and dept in anyway we go..
for every coleg whose coleg code is available i want to generate usn [University Seat Number] for all students of all dept in dat coleg..
this usn will be used in my later code to perform some operations [like one of the operations is to search my db for usn]
Currently im thinking to insert the college code and all the dept of the coleg in database table but getting confused as the no of dept in colleg varies..
Thanks for the extra info.. another question: you said that the data is in a file - do you want to put it into a database, or you'd be just as happy to read the data from the file, process it, and output the results?
it will be difficult to read the data from the file as i said its not in a proper order ..
i can manage to write a insertion query to insert that into db, but not able to decide structure of the db table...
if we create PHP class or var, it has to get initialized every time its being executed so i think it wil b good if we insert into db, and then run a select query for all the colleges [one college at a time inside the for loop] .... but even here the select query will b performed multiple times so dnt kno to go with PHP or db way....
OK, so lets think about the db structure to put the data into.. so the seat number and the batch are generated, not stored, right? In which case, I guess all you actually need in your DB table is the college code, and the department code.
Do you have any other data that you'll need to store along with this? If you were going to store additional info about each college, for example, then you'd probably want a separate table for colleges.
other info like college name, college location we can add ...
one more thing here is in each coleg , for a particular dept there will b one max no of seats available in dat dept [i.e intake]
example in a college 'XYZ' in 'CS' dept there can be 60 seats available, in 'EC' dept 100 seats available , in another college these numbers may differ...
so to brief up data needed to be stored...
colege code, colleg name, college location, diff depts in dat college, no of seats available in dat dept in that college
So, I think you need two tables.. college and department, which would be something like this:
code <-- as this value is unique to each college, you can use it as the primary key
state <-- add any req fields for the location
id <-- auto-incremented id as the primary key
code <-- department code
college_code <-- foreign key, references the primary key of the college table
That should give you a good structure to build on.. we can easily write a JOIN query to pull out all the data needed to generate the USNs.
already trying out with a table structure which i thought...max seats causing lil prob.. if mine doesnt work will try urs..
Thanks a lot bro..
and in ur dept table why do we need id ?? we can make a table without that primary key right ? this table is going to become very big so...
The id is there to provide a unique key for each record.. we couldn't any of the other columns as non of them will be unique (there will be multiple records with the same college code, for example).
Edit: Having a primary key speeds up access to the table, too.
oh den will add the primary key too... haha.. using ur table structure with an additional table having the names of all the department..
This topic is now closed. New replies are no longer allowed.