MySQL Forums
Forum List  »  InnoDB

Re: difrent id in a relational DB?? how?
Posted by: Peter Brawley
Date: January 30, 2015 10:02AM

> i want the id for shop 1 to be form 1 to 5 and for shop 2 if i have there 3 customers the id should be from 1 to 3

What purpose would that serve? Primary keys have just one function: uniquely identify the rows they're in. It's a design mistake to load them down with other significance.

shops( shopID int unsigned primary key, ...)
customer( custID int unsigned primary key, ...)
products( prodID int unsigned primary key, 
          shopID int unsigned,
          custID int unsigned,
          foreign key(shopID) references shops(shopID),
          foreign key(custID) references shops(custID)
)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: difrent id in a relational DB?? how?
1036
January 30, 2015 10:02AM
1068
February 03, 2015 10:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.