本文介绍了数据库设计需要这种小型业务逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个网络应用程序,其中我有用户,在创建用户时,我有位置,这些位置是分层模式,就像国家{包含}城市, Citites {包含}状态, 国家{包含}地区 与我的系统相同我有 区---------- {包含1 ... *} -------------------------------------> tehsils tehsils ---------- {contains 1 ... *} ---------------------------- ---------> UCS UCS ---------- {包含1 ... *} ----------- -------------------------->村庄 我可以将一个用户分配到一个或多个区域,一个或许多Tehsils,一个或多个UCs,一个或多个村庄 所以顶级实体比Tehsil区域而不是UC而不是村庄我在我的应用程序中执行此操作时不用担心:)。 现在我在我的应用程序中有问题,它就像一个测验引擎,我通过我的系统为每个用户分配问题所以每个问题也有目标价值就像 Q#01:学校数量(目标= 12){对于地区=ABC} 答案:已成功(10) 现在我想问你一个数据库设计我需要创建多少表以及它们之间的关系 我想要根据位置分配目标值,例如一个问题可以具有基于区域的目标值,或者Tehsil,或者UC,或者村庄,但不是所有的同时因此用户必须回答问题,就像回答目标值的实现值一样区ABC 我可以制作单个表格,如 表格(Question_ID,UserID,District,Tehsil,UC,Village,Target,Achieved) 这意味着它将根据位置插入目标与实现的值,如果选择了区域,那么它将插入就像那样) 表(Question_ID,UserID,District,Tehsil,UC,Village ,Target,Achieved) VALUES(1,2,'ABC',NULL,NULL,NULL,10,1) 将NULLS放入其他lo阳离子好吗? 我需要提前帮助... :) 我尝试了什么: 我做了一个简单的表就像那样 表(Question_ID,UserID,District,Tehsil,UC,Village,Target ,已实现)I have a web application in which i have users and while creating users i have locations and these location are in hierarchical pattern just like Country {contains} Cities,Citites{contains} States,States{contains} regionssame as according to my system i have District ----------{contains 1...*}------------------------------------->tehsilstehsils----------{contains 1...*}------------------------------------->UCSUCS----------{contains 1...*}------------------------------------->Villages I can assign a single user to one or many district , one or many Tehsils,one or many UCs,one or many Villages so Top Level entity is District than Tehsil than UC than Villages i am doing this all in my application no worry :).Now I have Question in my application and it is just like a quiz engine , I am assigning Question to each user through my system so each question also having Target value just like Q#01: Number of schools Constructed (Target =12) {for District = "ABC}Answer:Achived (10)Now I want to ask you a db Design how much table i have to create and the relationship between them I want to assign the target value based on location like one question can have a Target value based on District , or Tehsil, OR UC,OR Village but not all at the same time so user must answer the question relatively like answer achieved value for target value for District "ABC"can i make a single table just like Table(Question_ID,UserID,District,Tehsil,UC,Village,Target,Achieved)it means it will insert the target vs achieved value based on location if district is selected then it will insert just like that)Table(Question_ID,UserID,District,Tehsil,UC,Village,Target,Achieved)VALUES(1,2,'ABC',NULL,NULL,NULL,10,1)putting the NULLS for other location is it ok ?I need assistance thanks in advance ... :)What I have tried:I have made a simple Table just like that Table(Question_ID,UserID,District,Tehsil,UC,Village,Target,Achieved)推荐答案 这篇关于数据库设计需要这种小型业务逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-22 16:52