Re: quick question - multiple database tables -
07-13-2003
, 03:10 PM
Post the structure of your table like so to the group:
TableName
- FieldName (description if necessary)
- FieldName (...)
Generally speaking, a record/row in a table/view represents an instance of a
entity in your application. You mention user authentication, so User is an
entity (table name = Users)...is the user a customer, an employee an
administrator? Getting a more specific meaning of your entity offers greater
explanation to the purpose of the table (Customers is more meaningful that
User, if the site is commerce related).
With that said, the fields in the table describe characteristics of the
entity, or its associations to other entities in the application.
Imagine this scenario: A Student registers for classes by entering their
firstname, lastname and security credentials (desired username, password).
Upon submittal they are assigned a unique id. A Student can register for one
or more classes by choosing the course number and desired attendance period
(summer, fall, winter, spring).
So, picking out the entities we have Students, Classes and an association
between Students and Classes (a student can register for one or more
classess -- 1 to N relationship - 1 Student, Many Classes).
Students
- StudentID (Autonumber)
- Firstname
- Lastname
- Username
- Userpass
Classes
- ClassID (e.g 'HUM101', 'ECO101')
- ClassName (e.g 'Humanities 101')
- Period (one of fall, summer, winter, spring)
Note that the Student table does not have fields to represent the courses
they are taking. The 1 to N relationship between Students & Classes is
handled by a linking table:
Student2Classes
- StudentID
- ClassID
A student with StudentID 2001 can have many entries in Student2Classes if
that student is taking more than 1 class. A Student with ID 3003 can have no
entries if that student is not taking classes.
Anyways, hope that helps some.
--
Ron |