Can anybody let me know if your table inside a relational database (for example MySQL / SQL SERVER) could be with no primary key?

For instance, I possibly could have table day_temperature, where I register temperature and time. I do not begin to see the reason to possess a primary key for this type of table.

Wouldn't the main key naturally function as the time? can you have several temperature for any with time?

A much better question to request could be, "Why can you ever create a table without a principal key"

Technically, you are able to declare this type of table.

However in your situation, the time ought to be made the PRIMARY KEY, becasue it is most likely wrong to possess different temps for the similar some time and most likely useless to possess same more often than once.

Realistically, each table must have a PRIMARY KEY to ensure that you can distinguish two records.

Without having an applicant type in you data, just produce a surrogate one (AUTO_INCREMENT, SERIAL or whatever your database offers).

The only real excuse because of not getting a PRIMARY KEY is really a log or similar table the industry susceptible to heavy DML and getting a catalog onto it will impact performance beyond the amount of tolerance.

You do not need a PK, but it is suggested you have one. It's the easiest method to identify unique rows. Sometimes you wouldn't want a car incremental int PK, but instead produce the PK on another thing. For instance inside your situation, if there's just one unique row per time, you need to produce the PK around the time. It can make looks up according to time faster, and it also guarantees that they are unique (you can be certain the data integrity is not violated):

Like always it is dependent.

Table doesn't have to possess primary key. A lot more important would be to have correct indexes. On database engine is dependent how primary key affects indexes (i.e. produces unique index for primary key column/posts).

Inside your situation I'd give a new auto increment unique column like temp_id making it primary key. It makes much simpler maintaining this table -- for instance finding and getting rid of records (i.e. copied records).

If the potential of getting duplicate records (for instance for the similar time) isn't a problem, and also you don't have a much to question for specific records or selection of records, that you can do with no type of key.

Should you wound up with duplicate records you'd find it difficult to update or remove one with no PK (though it might be possible via ROW_NUMBER())

Time would then become the perfect primary key. It can help index that column to ensure that you are able to query data according to say to start dating ? range. The PK is exactly what ultimately makes your row unique, so inside your example, the datetime may be the PK.

I'd incorporate a surrogate/auto-increment key, particularly if there's any chance of duplicate time/temperature blood pressure measurements. You'd don't have any other to distinctively identify a replica row.

I have got a much better illustration of a table that does not require a primary key - a joiner table. Say I've got a table with something known as "abilities", and the other table with something known as "groups", and that i desire a joiner table that informs me all of the abilities that the particular groups may have, therefore it is basicallly

create table capability_group
(  capability_id varchar(32),
    group_id     varchar(32));

There's pointless to possess a primary key on that, since you never address just one row - you can either want all of the abilities for any given group, or all of the groups for any given capabilty. It might be better to possess a unique constraint on (capabilty_id,group_id), and separate indexes on fields.