Question:
explain what is a primary keys?
life4star2004
2007-01-30 05:33:17 UTC
explain what is a primary keys. and why is it needed for the admin staff to use in a secondry school. and can you talk about the filed size and the reason why you have to sometimes change the filed size
Three answers:
ravydavygravy01
2007-01-30 05:39:47 UTC
if you're talking about databases



About primary keys (MDB)

Show All

Hide All

The power of a relational database system such as Microsoft Access comes from its ability to quickly find and bring together information stored in separate tables using queries (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form, report, or data access page.), forms (form: An Access database object on which you place controls for taking actions or for entering, displaying, and editing data in fields.), and reports (report: An Access database object that prints information that is formatted and organized according to your specifications. Examples of reports are sales summaries, phone lists, and mailing labels.). In order to do this, each table should include a field or set of fields that uniquely identifies each record stored in the table. This information is called the primary key of the table. Once you designate a primary key for a table, Access will prevent any duplicate or Null (Null: A value you can enter in a field or use in expressions or queries to indicate missing or unknown data. In Visual Basic, the Null keyword indicates a Null value. Some fields, such as primary key fields, can't contain Null.) values from being entered in the primary key fields.



There are three kinds of primary keys that can be defined in Microsoft Access:



AutoNumber primary keys



An AutoNumber (AutoNumber data type: In a Microsoft Access database, a field data type that automatically stores a unique number for each record as it's added to a table. Three kinds of numbers can be generated: sequential, random, and Replication ID.) field can be set to automatically enter a sequential number as each record is added to the table. Designating such a field as the primary key for a table is the simplest way to create a primary key. If you don't set a primary key before saving a newly created table, Microsoft Access will ask if you want it to create a primary key for you. If you answer Yes, Microsoft Access will create an AutoNumber primary key.



AutoNumber primary keys in a replicated database



There are additional considerations if your table will be used with database replication (database replication: The process of creating two or more special copies (replicas) of an Access database. Replicas can be synchronized, changes made to data in one replica, or design changes made in the Design Master, are sent to other replicas.).



If fewer than 100 records are routinely added between synchronizing replicas (replica: A copy of a database that is a member of a replica set and can be synchronized with other replicas in the set. Changes to the data in a replicated table in one replica are sent and applied to the other replicas.), use a Long Integer setting for the FieldSize property to take up less disk space.



If more than 100 records are routinely added between synchronizing replicas, you should use Replication ID for the FieldSize property setting to prevent records from being assigned the same primary key value in each replica. Note, however, that an AutoNumber field with a Replication ID field size produces a 128-bit value that will require more disk space.



Single-field primary keys



If you have a field that contains unique values such as ID numbers or part numbers, you can designate that field as the primary key. You can specify a primary key for a field that already contains data as long as that field does not contain duplicate values or Null values.



Multiple-field primary keys
nephilim_erich
2007-01-30 13:50:23 UTC
The primary key of a relational table uniquely identifies each record in the table. It can either be a normal attribute that is guaranteed to be unique (such as Social Security Number in a table with no more than one record per person) or it can be generated by the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server). Primary keys may consist of a single attribute or multiple attributes in combination. Imagine we have a student records database that contains three tables. The first table, STUDENTS, contains a record for each student at the university. The second table, CLASSES, contains a record for each class session offered. The third table, ENROLLMENT, contains student enrollment records (e.g. each record represents a single student enrolling in a single course). There would be multiple records for each student (representing all the classes that student is enrolled in) and multiple records for each class session (representing all the students enrolled in that class). A student's unique student ID number would be a good choice for a primary key in the STUDENTS table. The student's first and last name would not be a good choice, as there is always the chance that more than one student might have the same name.



hope that helps a little....
Iridflare
2007-01-30 14:02:14 UTC
Imagine you've got a table in a database that includes first names, last names and addresses. If you want to find Joe Soap's address you'll need to read all the first names to find all the Joes, and then find which one is Joe Soap. That's a slow way of doing things, and it'll get slower the more data you've got in your database. If you give everyone their own unique number and add that to the table, you only need to look for the unique number, so it's quicker. That unique number is the primary key. In a real database there are special methods to handle primary keys, so the searches are very fast.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...