节省座位安排在Mysql表中 [英] saving seat arrangement in Mysql table

查看:177
本文介绍了节省座位安排在Mysql表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi可以有人建议我一种方式来节省座位安排,这是一个mysql表中的nxm矩阵。以下是我们如何生成nXm表




  • Admin指定总线的行数和列数

  • 管理员选择矩阵的特定元素是


    1. 座位


    2. 睡眠

    注意:睡眠者占据2个元素


  • 此矩阵必须保存在数据库中



我希望矩阵的每个元素都具有唯一性id在一个睡眠者的情况下有两个元素相同

解决方案

MatrixTable

  | MatrixID | Rows | Colls | 

其中MatrixID是主键



SeatTakenTable

  | MatrixID | Row | Column | PassangerType | ElementID | 

其中所有列都是复合主键



<

对于一个睡眠者,你将hae插入两行具有相同ElemntID


的SetTaken表

Hi can some one suggest me a way to save seat arrangement which is nXm matrix in a mysql table. Following are how we generate the nXm table

  • Admin specifies the no of rows and column of a bus
  • Admin selects whether a particular element of matrix is a

    1. Seat
    2. Passage
    3. Sleeper

    Note: A sleeper occupies 2 elements

  • This matrix has to be saved in the database

I want each element of the matrix to have a unique id with one exception in case of a sleeper two elements are same

解决方案

MatrixTable

|MatrixID|Rows|Colls|

where MatrixID is the primary key

SeatTakenTable

|MatrixID|Row|Column|PassangerType|ElementID|

Where all Columns are the composit primary key

There is no nead to save free seats because there wont be any collusions when you use this "logical" key

For a sleeper you will hae to insert two rows in the SetTaken table with the same ElemntID

这篇关于节省座位安排在Mysql表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆