There are few keys define in the MySQL, they are:
- Primary key
- Foreign key
- Compound key
It is a uniquely identified key in each records in the defined database. It does not contain "Null" values. Almost all table contains the primary key. The creation of primary key should be define while we are creating table into the database, else we need to alter the table as per our definition requirements.
columnname datatype(size) NOT NULL PRIMARY KEY
create table studper(pid int(3) not null primary key auto_increment, sid int references studinfo(sid), fathername varchar(20), mothername varchar(20));
In the above code we have define the 'pid' as a Primary key which is 'not null' and can be 'auto_increment' its value.
As the name define foreign, its foreign to the other table, means if a primary key is present or declare in the different table and it can be used in different table as a column so its declare as a foreign key in the used table.
columnname datatype references tablename(columnname or Primaykeyname)
In the above code we have define "sid" as a foreign key in the current table(studper) and tablename is studinfo is the references table in which reference column name is sid.
It is a key that consists of multiple columns, because one column is not sufficiently unique in the define table. It also called composite key.
It is the process of representing the essential features. there are three forms of schemas or level define they are:
In this level of schema it describes details of how data is stored: files, indices, etc. on the other access disk system. It also describes the record layout of files and type of files structure we are using like hash, b-tree,etc. It describe the low level of abstraction structure in detail.
In this level of schema, it describes what type data are stored in the database, and what relationships exist among those data. It is also refered as the logical level.
In this level of schema it presents data as a set of relations. It specifies a view of the data in terms of the conceptual level. it also referred as the view level.