A Table can have a Composite Primary Key which is a primary key made from two or more columns. For example:
CREATE TABLE userdata (
userid INT,
userdataid INT,
info char(200),
primary key (userid, userdataid)
);
Update: Here is a link with a more detailed description of composite primary keys.
More Related Contents:
- Surrogate vs. natural/business keys [closed]
- What are the design criteria for primary keys?
- What’s the difference between identifying and non-identifying relationships?
- What’s wrong with foreign keys?
- What are database normal forms and can you give examples? [closed]
- NoSql vs Relational database
- Multiple schemas versus enormous tables [closed]
- First name, middle name, last name. Why not Full Name?
- Best practices for storing postal addresses in a database (RDBMS)?
- Can we update primary key values of a table?
- Oracle (ORA-02270) : no matching unique or primary key for this column-list error
- Techniques for database inheritance?
- What is the most efficient way to store tags in a database?
- Microservices with shared database? using multiple ORM’s? [closed]
- Deciding between an artificial primary key and a natural key for a Products table
- What are the advantages of using a single database for EACH client?
- In terms of databases, is “Normalize for correctness, denormalize for performance” a right mantra?
- How should international geographical addresses be stored in a relational database?
- Still Confused About Identifying vs. Non-Identifying Relationships
- Which is a good design for a database table that can be owned by two different resources, and therefore needs two different foreign keys? [closed]
- Ideas on database design for capturing audit trails [closed]
- Alternatives to Entity-Attribute-Value (EAV)?
- Is it better to use multiple databases with one schema each, or one database with multiple schemas? [closed]
- Strings as Primary Keys in MYSQL Database [closed]
- Is it a good idea to use an integer column for storing US ZIP codes in a database?
- Versioning Database Persisted Objects, How would you? [closed]
- Best design for a changelog / auditing database table? [closed]
- Should a database table always have primary keys?
- Databse architecture (single db vs client specific db) for Building Enterprise Web (RIA) application on cloud
- Derived account balance vs stored account balance for a simple bank account?