To create a table in MySQL you will need to use the CREATE TABLE function. This is simple enough to use, a simple example of creating a users table is below, it has a unique id (Primary Key) with a unique username and a password field (which I would recommend storing as an MD5). CREATE TABLE users (id INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , username VARCHAR( 16 ) NOT NULL , password CHAR( 32 ) NOT NULL , UNIQUE ( username ) );
The field in a related table that matches a field in another table is called a foreign key. This foreign key establishes the relationship between the two tables in a database.
key
Its best to choose an ID for each table to use as the Primary Key (PK). This is best as an INT due to speed.
Field Name of the table field.Type Column type such as varchar or timestamp.Null Does the field allow null values?Key Is this field a primary key or (a part of) and index?Default Default field value.Extra Additional information such as "on update CURRENT_TIMESTAMP"
No, a primary key do not refers to the whole table .A primary key refers to a field in the table that is not null and unique.
True.
Foreign key field
key field
Access automatically creates an index for the primary key field in a table. In addition, Access automatically creates an index for any field name that contains the following letter sequences: code, ID, key, or num.
The foreign key is used as a reference in a table to the primary key of another table. For example: consider a table employee with id(primary key), name, address,department_id(foreign key) as its fields.Another table department with fields department_id(primary key) and dept_name. So, department_id is primary key in department table and foreign key in employee table.
The primary key.