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.
相关阅读
今天才发现 Oracle Application Express 很牛学db2 iseries 会有很多工作机会么?Entry level BDA请教一下高手,包子答谢!关于:DB developer VS DBA 就业前景求问一个对我来说很难的问题how to find and kill process I don't want包子请教queryMassive deleting in MYSQL请教2个sql query 问题怎样找odd和even row问一个可能看起来很怪的问题请问: Oracle database 10g OCA, OCP forum如何用SQL从MS access中提取table filed nameWhat's the most economical way to get OCP certifitation?Deadlock on merge (oracle)SQL Server 2008 vs. Oracle 11g (from MS)事务处理这门课值得学吗?Which one is better?"?" in prepared statement cannot be table name ?