s*e
2 楼
Design a table managing students and classes that a student takes.
There are two ways:
1. Using a vector as a column. The number of bits is equal to the number of
classes. "1" means enrolling in a class. "0" means not.
StudentID Class-vector
100 00110100
101 11010000
2. Use class name as a column.
StudentID ClassName
100 class3
100 class4
100 class6
101 class1
101 class2
101 class4
The number of class is not fixed. So
There are two ways:
1. Using a vector as a column. The number of bits is equal to the number of
classes. "1" means enrolling in a class. "0" means not.
StudentID Class-vector
100 00110100
101 11010000
2. Use class name as a column.
StudentID ClassName
100 class3
100 class4
100 class6
101 class1
101 class2
101 class4
The number of class is not fixed. So
B*g
4 楼
2
Create 2 index
of
【在 s****e 的大作中提到】
: Design a table managing students and classes that a student takes.
: There are two ways:
: 1. Using a vector as a column. The number of bits is equal to the number of
: classes. "1" means enrolling in a class. "0" means not.
: StudentID Class-vector
: 100 00110100
: 101 11010000
: 2. Use class name as a column.
: StudentID ClassName
: 100 class3
Create 2 index
of
【在 s****e 的大作中提到】
: Design a table managing students and classes that a student takes.
: There are two ways:
: 1. Using a vector as a column. The number of bits is equal to the number of
: classes. "1" means enrolling in a class. "0" means not.
: StudentID Class-vector
: 100 00110100
: 101 11010000
: 2. Use class name as a column.
: StudentID ClassName
: 100 class3
s*q
5 楼
谢谢你!
s*e
6 楼
Thanks.
How about the following two indexes:
1.
CREATE UNIQUE INDEX sid ON mytable (StudentID, ClassName)
This is for search like: SELECT * WHERE mytable.StudentID==100
2.
CREATE UNIQUE INDEX class ON mytable (ClassName, StudentID)
This is for search like: SELECT * WHERE mytable.ClassName==class2
【在 B*****g 的大作中提到】
: 2
: Create 2 index
:
: of
How about the following two indexes:
1.
CREATE UNIQUE INDEX sid ON mytable (StudentID, ClassName)
This is for search like: SELECT * WHERE mytable.StudentID==100
2.
CREATE UNIQUE INDEX class ON mytable (ClassName, StudentID)
This is for search like: SELECT * WHERE mytable.ClassName==class2
【在 B*****g 的大作中提到】
: 2
: Create 2 index
:
: of
B*g
8 楼
I think 1 is only good (compare to index(StudentID))for
SELECT StudentID, ClassName WHERE mytable.StudentID==100
But if you server is "strong", I think your design is good.
【在 s****e 的大作中提到】
: Thanks.
: How about the following two indexes:
: 1.
: CREATE UNIQUE INDEX sid ON mytable (StudentID, ClassName)
: This is for search like: SELECT * WHERE mytable.StudentID==100
: 2.
: CREATE UNIQUE INDEX class ON mytable (ClassName, StudentID)
: This is for search like: SELECT * WHERE mytable.ClassName==class2
SELECT StudentID, ClassName WHERE mytable.StudentID==100
But if you server is "strong", I think your design is good.
【在 s****e 的大作中提到】
: Thanks.
: How about the following two indexes:
: 1.
: CREATE UNIQUE INDEX sid ON mytable (StudentID, ClassName)
: This is for search like: SELECT * WHERE mytable.StudentID==100
: 2.
: CREATE UNIQUE INDEX class ON mytable (ClassName, StudentID)
: This is for search like: SELECT * WHERE mytable.ClassName==class2
n*6
10 楼
Yeah.
It's better to understand what are the most frequently used query.
If a lot of request for
SELECT StudentID, ClassName WHERE mytable.Student ID = 100
then it is good.
【在 B*****g 的大作中提到】
: I think 1 is only good (compare to index(StudentID))for
: SELECT StudentID, ClassName WHERE mytable.StudentID==100
: But if you server is "strong", I think your design is good.
It's better to understand what are the most frequently used query.
If a lot of request for
SELECT StudentID, ClassName WHERE mytable.Student ID = 100
then it is good.
【在 B*****g 的大作中提到】
: I think 1 is only good (compare to index(StudentID))for
: SELECT StudentID, ClassName WHERE mytable.StudentID==100
: But if you server is "strong", I think your design is good.
j*n
12 楼
figure out what is many-to-many relationship.
A*2
13 楼
我觉得水粉画出来的画比丙烯画更接近油画的色彩,
但是不如丙烯画好保存。大家有没有同感?
还是我买的丙烯颜料太亮了?
但是不如丙烯画好保存。大家有没有同感?
还是我买的丙烯颜料太亮了?
s*e
14 楼
If I create index only on the first column, like:
CREATE INDEX sid ON mytable (StudentID)
The index will not be an unique index. The following query will return many
rows, right?
SELECT StudentID, ClassName WHERE mytable.Student ID = 100
【在 n********6 的大作中提到】
: Yeah.
: It's better to understand what are the most frequently used query.
: If a lot of request for
: SELECT StudentID, ClassName WHERE mytable.Student ID = 100
: then it is good.
CREATE INDEX sid ON mytable (StudentID)
The index will not be an unique index. The following query will return many
rows, right?
SELECT StudentID, ClassName WHERE mytable.Student ID = 100
【在 n********6 的大作中提到】
: Yeah.
: It's better to understand what are the most frequently used query.
: If a lot of request for
: SELECT StudentID, ClassName WHERE mytable.Student ID = 100
: then it is good.
相关阅读
Has anybody used Sybase? Urgent help!How to change Access specification?Perl安装DBD::oracle的问题(linux,server不在本机)Need help on VBA! Please!愿闻其详Re: Can I ....问个初级问题Help needed on SAP[转载] 想自学MS. Access and Excel,网上哪儿有比较好的如何获得把Oracle9i从9.2.0.1升级到9.2.0.4的补丁?怎么做哈OK, found the right tool.请问哪里有sql语句追踪工具VBA FOR EXCEL 问题请教,ONLINE WAITINGCan I create thousands table in one...AW and Shuke Re: Can I...问个初级问题.不要笑话mysql怎么绕过嵌套查询?database overflow请教一个关于JDBC的问题,实在太烦了!sql questionRe: 诚心请教 (SQL) => Try This Please: