Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

composite-primary-key

How to properly create composite primary keys – MYSQL

October 12, 2022 by Tarik

I would use a composite (multi-column) key. CREATE TABLE INFO ( t1ID INT, t2ID INT, PRIMARY KEY (t1ID, t2ID) ) This way you can have t1ID and t2ID as foreign keys pointing to their respective tables as well.

Categories mysql Tags composite-key, composite-primary-key, myisam, mysql, primary-key Leave a comment

Can I have multiple primary keys in a single table?

September 17, 2022 by Tarik

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.

Categories database Tags composite-primary-key, database, database-design, primary-key Leave a comment

Sqlite primary key on multiple columns

September 8, 2022 by Tarik

According to the documentation, it’s CREATE TABLE something ( column1, column2, column3, PRIMARY KEY (column1, column2) );

Categories sqlite Tags composite-primary-key, ddl, primary-key, sqlite Leave a comment
Newer posts
← Previous Page1 Page2 Page3

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa