I am trying to do my very first VS2005 project using VB. Problem is I'm at a disadvantage because I don't know VB but am determined to learn VS. Anyway, this is what I'm trying to accomplish. I am building a web app for student registration. Currently, the parent must complete a multitude of paper forms, many with the same information, at registration. I am developing the web app to include data entry pages that will capture the data to SQL tables, give the parent an opportunity to review their data and edit any errors and submit it. I will then create another "console" page that will be used by staff so they can print a page that contains all the data, for each student that the parent will sign.
Okay so dumb ?...householdid will be used and need to be updated to a few different tables. In other words, here is the household, related to these 3 students, related to these 2 parents, etc. So my thinking is household table=householdid, student table has studentid (INT) and householdid, contact table has personid(INT) and studentid and may or may not have a householdid (student can have contacts that do not live in the house). So do I store session("house")=householid in the global.asx page in the Session section since it maybe used multiple times? And if so, what do I do on the student.aspx page? Do I add a hiddenfield = to that session, which then updates the student table along with the other data on the student form?
Lots more ?? to come I'm sure!
All good questions, and a valid way to do it. I'd tend not to use the global.asx for any of this and instead use a login/logout and retrieve the id from the database for a valid login. I'm not sure your database is the best setup, but I don't know any of the entites or their relationships so I can't judge. Since you're in 2.0 look into Membership/Profiles for a decent method of handling a lot of this as well.
Jeff
Thanks for the reply. I do not want to require parents to login so would I still use Membership/Profiles?? Can you give me some suggestions on database setup that might be more efficient?
If you're not logging in it's hard to verify any identities, let alone use a membership or profile. What's to keep parents from changing/viewing some other kid? As for database, I don't know that your design is inefficient, I don't really know anything about the data at all.
Jeff
MMM, if the form is set to insert mode, how could a parent even search to edit another student? I originally set this up with a form on a page, with several pages and a "next" button on each page with each form submitting/inserting the data to SQL. But would it be better if I used the "Wizard" control? Can I use a Form View or DetailsView and just enable Inserting? Also if the Wizard is better, how do I get it to insert the data into the SQL table?
Well, how are you choosing the record to insert? I'm assuming you're selecting the student by student ID, so somewhere you have to retrieve this id. It can't be universal in the application, at some point a parent has to identify who they are or who their kid is to be able to insert the correct information and relate it to that kid.
I may be missing something here, since I haven't seen the app or the database structure. You can use any method you wish, it really depends more on what you want as a front end than what happens on the back end.
Jeff
Remember, this is my first try at VS so I may not be thinking correctly! But I want the parent to go to a web site, have a series of data entry forms that all they can do is insert. I guess they will need to somehow be given a chance at some point in the Wizard Steps to verify and correct any errors.
The parent will then physically come into the registration center and all of the data will be reviewed and a few more things added by staff only, and staff will then print out a hard copy form for the parent to sign. So the relationship that I envision is this which is how our student information application works so the data structure is similar; parent enters address, DB creates an identity key called householdid in household table. Then they enter the information about each of their students, and each student has an identity key in student table and included in that student table is householdid (so one household, one or multiple students). Then they enter the information about themselves, the parents and/or contacts for those students just entered and each parent/contact has a personid identity in contact table. Now here is where I can't quite figure out what to do...each parent/contact has a relationshiptype and may or maynot share the same householdid (it may just be an emergency contact that doesn't live in the household) but I need to relate all three...household, student and parent/contact.
For staff I was thinking of doing like a grid and detail page. Am I totally going in the wrong direction here?
I think if you step back and grap a pad of paper to do an entity relationship diagram you'll get this sroted out faster. In the database world, entities are things. Such as students, households, classes, contacts, etc. They have relationships, such as one parent can have more than one kid, but each kid can only have one parent. And each kid belongs to a household, but a contact may or may not belong to a household. Attributes of an entity are things like address, name, phone, etc. In the end, entities become database tables, attributes become the fields/columns in a record, and the relationships between them define how they interact. Each entity is a record in a table, so that Johnny, Jimmy and Susie are all records in the students table. Each individual entity has a single record only, making them a unique item. Normally you would give them a unique ID attribute, such as StudentID, ParentID, HouseholdID, ClassID, etc.
If you have entities that relate then you have foreign keys in your database. Entities can have a one to one relationship, a one to many or many to one relationship or a many to many relationship. For example more than one student can have the same parent, a many to one relationship. A student can have many classes and a class can have many students, a many to many relationship. In a many to one relationship, a foreign key is assigned, so that the student table has a parent ID column that links to their parent in the parent table. In a many to many relationship, you use a linking table with two fields, the StudentID and the ClassID for example.
In Query langauges you have joins and other techniques to handle retrieving the data across the tables. For example, a student's name is a field in the student table, a class time is a field in the class table and you have a joining table with ClassID and StudentID fields. The question you want an answer to is:
"Give me all the class times for John"
The query goes something like (Not real query code):
SELECT ClassTime FROM ClassTable WHERE StudentClasses.StudentID = Students.StudentID for John AND StudentClass.ClassID = Classes.ClassID
This looks up the StudentID for John in the Students table and finds every match in the StudentsClasses table, then taks the corresponding ClassID and looks it up in the Classes table and prints out the class time.
So getting a handle on the underlying structure and the relationships goes a long way to deciding how the code will look and work. Whether you display it in a grid, a detail page, a repeater or tattoo it on the forearm of a welder at Bernie's Body Shop is all just a choice in how you want the end result displayed. And those are the easy parts.
Thus concludes Database Design 101... :)
Jeff
Okay, thanks! I think I might have that part more clear now!! I "basically" had the tables structured like that but have made a couple changes.
So that "easy part" you were talking about...I have two version started, one with multiple pages that use form view to insert records and a next button to take them to next page. And also a Wizard Control that I have used a DetailsView to insert. But I still don't understand how to retrieve the householid, for example, from the first page after it inserts the record and pass it to the next page .
0 comments:
Post a Comment