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.
相关阅读
帮忙选择服务器抛砖引玉: 谈谈SQL Server locking and blockingtemp table problemSQL 2000 create index 問題Oracle 11gR2 for x64 windows out谁能帮我看看怎么RE-WRITE这段CODE?why use anonymous block when calling stored procedure?新人报道Help达人推荐几个SQL的入门认证(非计算机专业)Solution suggestions?问个external table field definition的问题新人DBA报道,DB2请教如果Do replicated tables need identical?请教:空间数据库排序Any cumulative distribution function of normal distribution implemented in SQL?讨论:你愿意做manager吗?How to query MS Access in command line公司用Salesforce平台的一个数据库,问发展方向